...
Only 10 of the bits read from the ADC contain useful data (LSB/MSB determines which bits), the rest will need to be ignored.
The ADC digital value will range from the maximum to minimum value 10 bits can hold.
(What is the largest number that 10 bits can hold?)
The timer will need to be started only once in the program.
Remember that the duty cycle must range from 5-10% of the total period or 1-2ms of on time and the ADC value will need to be converted to counts.
Additional Resource:
Best Practices
For the Firmware team we follow a naming and code style guide to make our code more uniform and readable
...
To submit your work for review, create a pull request of your fork against the UWARG/embedded-bootcamp repository. Name your pull request Bootcamp: YOURNAME
. Tell the responsible team lead that you've completed the bootcamp in the #Bootcamp
Discord channel and they will have someone review your submission. You may be asked to revise some things.
General Hints
For PWM, you will need to use timer 1 to create a PWM signal. The signal should be at 50Hz, with an on-time ranging from 1ms - 2ms. To achieve this frequency, you will need to change the prescaler and period in
tim.c
. Note that the input clock frequency is 48 MHz. To change the duty cycle, you will need to set the compare register using the HAL library APIs.Look at the HAL_ADC_, HAL_TIM_, and __HAL_TIM_ functions to access the timers and ADCs. The HAL User Manual will be particularly useful here.
The electrical schematic is useful for determining which pins should be configured to which peripheral.