cancel
Showing results for 
Search instead for 
Did you mean: 

Timer 16 bits is less stable than Timer 32 bits in PWM input mode

ManhPham
Associate II

Hello everyone,

I read PWM input value by Timer 16 bits in Nucleo-F767ZI (combined channel mode), but the value that I received is not the same after some days.

For example, Day 1: PWM input value = 4200 but Day 4: PWM input value = 4000, no code changed, I keep the same code.

When I change from Timer 16 bits to Timer 32 bits, PWM input value that I read is very stable. So I don't think the PWM input wrong, I think the problem is from Timer 16 bits.

Only difference is Timer 16 bits with Prescaler = 10 (to avoid timer overflow), Timer 32 bits with Prescaler = 0.

I face to the same problem with ADC, if I change the ADC channel, then ADC value change as well (keep the same resolution).

My question: Could anyone help me read PWM input more stable by Timer 16 bits?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sarra.S
ST Employee

Hello @ManhPham

I think the change of the prescaler is the key here; a PSC of 10 divides the clock frequency by 11, which reduces the timer's resolution compared to a prescaler of 0, also the 16-bit timer may be more prone to overflow, which can cause instability in the readings

Depending on your clock frequency, and the frequencies range you want to measure, calculate the PSC-max and min you can use, and test it 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2

Check:
Your code - at 90% you have something wrong there
Your clock and its stability
External signal period/frequency/duty cycle with independent measurment

Sarra.S
ST Employee

Hello @ManhPham

I think the change of the prescaler is the key here; a PSC of 10 divides the clock frequency by 11, which reduces the timer's resolution compared to a prescaler of 0, also the 16-bit timer may be more prone to overflow, which can cause instability in the readings

Depending on your clock frequency, and the frequencies range you want to measure, calculate the PSC-max and min you can use, and test it 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.