Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 21194

BASCOM-AVR : Problem with bitwise operation inside sub - Please help. : REPLY

$
0
0
Its been a while since I wrote some code, so perhaps I'm missing something, but: 1 MHz clock, divided by a Pre-Scaler 0f 1, gives a 1 MHz clock into the Timer/Counter. Setting the compare value to 46874 means that the T/C will have 46875 counts per period. The one extra count is for roll-over from the 46874 value back to 0. 1 MHz / 46875 gives 21.3 interrupts per second. Your comment indicates an interrupt once every three seconds. Next suggestion: If you want accurate timing one uses the T/C. If you want to toggle a port pin on a given time interval then don't poll the bit (flag) in a software loop. This adds an unknown delay. Just toggle the port pin in the ISR itself, then return. Lastly: Should Clear Timer = 1 be Clear_Timer = 1 I don't have a board out to test this at the moment. JC

Viewing all articles
Browse latest Browse all 21194

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>