Bootcamp: Shayne Yang - #324
Closed
ShayneYurnYang wants to merge 3 commits into
Closed
ShayneYurnYang wants to merge 3 commits into
ShayneYurnYang wants to merge 3 commits into
Conversation
Updated pin configurations for through STMCubeIDE
Initialize SPI-based ADC reads and drive a 50Hz PWM servo output from ADC values. Set chip-select (PA4) HIGH during init to avoid ADC desync, then start TIM1 PWM. In the main loop send a 3-byte SPI request, reconstruct a 10-bit ADC value from the response, map it linearly to timer compare counts (3200-6400) for 1–2 ms pulse width, and update TIM1 CH1. Also throttle loop with HAL_Delay(10). Adjust TIM1 period from 64000 to 63999 in both tim.c and the .ioc to correct the timer's autoreload value.
Add SERVO_MIN_PULSE, SERVO_MAX_PULSE and SERVO_PULSE_RANGE macros and replace hard-coded 3200/6400 values in main.c. The ADC-to-PWM interpolation now uses the named constants (with UL suffix) to compute compare_val, improving clarity and ensuring correct unsigned arithmetic when mapping 10-bit ADC values to timer counts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.