Skip to content

No compiler errors - Not hardware tested#301

Open
Z-Bedard wants to merge 3 commits into
UWARG:masterfrom
Z-Bedard:master
Open

No compiler errors - Not hardware tested#301
Z-Bedard wants to merge 3 commits into
UWARG:masterfrom
Z-Bedard:master

Conversation

@Z-Bedard
Copy link
Copy Markdown

This implementation was actually done earlier in the week, but I didn't create a thread until last night.

Comment thread nucleof072rb/nucleof072rb.ioc Outdated
SPI1.VirtualType=VM_MASTER
TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM1.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period
TIM1.Period=19999
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more optimal to have a higher period and lower prescalar value. Try to go for the most efficient values possible

Comment thread nucleof072rb/Core/Src/main.c Outdated
/* USER CODE BEGIN PV */

const uint16_t PWM_MIN_US = 1000;
const uint16_t PWM_MAX_US = 2000;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you would have to adjust these values after making changes to the timer peripherals

uint16_t adc_in = readADC(1);

uint16_t pwm_us = PWM_MIN_US + ((adc_in * (PWM_MAX_US - PWM_MIN_US)) / 1023);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1023 what? Using a constant or a preproccesser directive instead of magic numbers is always better.

{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work but you need to call the functions to use them in main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants