Hardware:
Led => Pin A0
Crystal 4MHz and 33pF caps => OSC1-2
1) Would it be a problem related to fuses?
2) "clear_interrupt()" is necessary on timer1_isr? (same as "T1IF = 0"?)
Thanks!
Last edited by lcs on Wed Jul 01, 2020 2:33 pm; edited 1 time in total
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
Posted: Wed Jul 01, 2020 2:21 pm
One issue I can immediately see is that you are using int for your ticks, which is an 8 bit value. That only will go up to 255 and then roll over to zero. Therefore you never reach 1000. You need to use int16 which will allow you to reach 65535 (unsigned).
I suggest looking at the type definitions in stdint.h which makes your types very explicit and easy to keep track of.
lcs
Joined: 10 Mar 2020 Posts: 6
Posted: Wed Jul 01, 2020 2:33 pm
dluu13 wrote:
One issue I can immediately see is that you are using int for your ticks, which is an 8 bit value. That only will go up to 255 and then roll over to zero. Therefore you never reach 1000. You need to use int16 which will allow you to reach 65535 (unsigned).
I suggest looking at the type definitions in stdint.h which makes your types very explicit and easy to keep track of.
AArrrgh
I forgot that "int" is int8 due to the use of other compilers.
I focused on other details and forgot the basics.
Solved. Thanks!
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