Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ATMega88PB calculating problem

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
nobner

Bascom Member



Joined: 29 Apr 2015
Posts: 14

germany.gif
PostPosted: Sat Oct 06, 2018 5:18 pm    Post subject: ATMega88PB calculating problem Reply with quote

Hello to all,
i'm counting two PWM-Pulses (500Hz) into PinC.1 and PinC.2 of an ATMega88PB (10MHz Crystal).
Therefore i'm using Timer1 with a Prescaler of 8.
Data input:
Start Timer1
Timer1 = 0
while PinC.1 = 1
wend
value = Timer1

this measurement i'm doing 10 times in a loop to achieve higher value for calculation

the single value is always correct, but the value calculated after the loop is wrong in ONLY ONE POSITION OF PWM:
Stepping down in 1Ás steps, it jumps at a value of 6300 about 200 digits to 6100. After that, counting is correct again (6100, 6090, 6080.....)
This means, that the 10 times counting loop is wrong on only this single position.
Stepping up, the same jump happens (6090, 6100, 6300, 6310, 6320...)
The PWM time at this issue is 630Ás

NEW:
i had a serial display attached on PortE.3 to show these values. When i take the display programm out of the code, everything works fine... don't understand this, because counting loop is in a complete other programm section.

I would be thankful for any suggestion.

kind regards
Norbert

(BASCOM-AVR version : 2.0.8.1 )
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2132

netherlands.gif
PostPosted: Mon Oct 08, 2018 10:14 pm    Post subject: Reply with quote

Without the rest of the code it's hard to help.
2 things regarding the code you posted.
Code:

Timer1 = 0
Start Timer1
Bitwait Pinc.1 , Reset
value = Timer1
 


Have fun.

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum