It is a simple project using PWM as output and ADC as input in a MSP430FR5969 Microcontroller, in other words, the output voltage (for example a LED) can
increase/decrease according to the ADC Value.
As you can see in the datasheet, you can configure different clocks for different utilities, so you can configure the clocks as your project needs.
in this case, the MCLK -> DCO = 1MHZ, the ACLK -> LFXTCLK (~32Khz) = 32.768 Hz and the SMCLK -> DCO (1Mhz / 32) = 31.250 hz
PWM
This example project uses the TimerB counter with the Up-Mode, and Reset/set mode.
The output is reseted when the timer counts to TBxCCR1 value, and it is set when the timer counts to the TBxCCR0 value, so hence it’s clear that
if the relation TBxCCR0/TBxCCR1 changes, the duty cycle PWM will also change.
Initialization ADC function:
It’s a 12-bit resolution ADC, therefore N=2^12= 4.096, so the LSB = 3.45v/4096 = 0.0008423 = 0.84mv difference for each bit.
as ADC12VRSEL = 0, Therefore VR+ = AVCC (3.45v) and VR-= AVss (0v).
Read ADC value and change the output
ADC12MEM0 is the register that holds the ADC Value.