Timeline for My own millis() function not accurate in the arduino
Current License: CC BY-SA 3.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 13, 2012 at 9:00 | answer | added | wesen | timeline score: 1 | |
Jan 9, 2012 at 17:31 | answer | added | vicatcu | timeline score: 3 | |
Jan 8, 2012 at 19:26 | vote | accept | 0xakhil | ||
Jan 8, 2012 at 18:55 | vote | accept | 0xakhil | ||
Jan 8, 2012 at 18:55 | |||||
Jan 8, 2012 at 18:55 | comment | added | 0xakhil | The bug was I didnt enable CTC mode in the Timer settings. So the internal timer counter always overflowed to 255. Adding "TCCR0A = 0b10;" to the main() solved the problem. Thanks to all for the support. | |
Jan 8, 2012 at 18:39 | comment | added | Majenko | You should have as little code as possible inside an interrupt service routine. Especially not heavy routines like Serial.println(). | |
Jan 8, 2012 at 18:28 | comment | added | bdutta74 | Oh one more thing. If you have a logic analyzer, in some cases you can completely do away with Serial console usage for program debugging, i.e. using pin toggling. Serial library is rather heavy both in terms of runtime performance, as well as impact on code size (~550B). This is especially important when you are doing it within ISR. With a slow sampling rate and RLE compression of samples, you could use the pin-toggling (for debug), quite effectively, with very little performance cost (unlike Serial library). | |
Jan 8, 2012 at 17:50 | history | edited | 0xakhil | CC BY-SA 3.0 |
added 4 characters in body
|
Jan 8, 2012 at 17:33 | history | edited | 0xakhil | CC BY-SA 3.0 |
deleted 286 characters in body
|
Jan 8, 2012 at 17:17 | history | edited | 0xakhil | CC BY-SA 3.0 |
deleted 117 characters in body
|
Jan 8, 2012 at 17:15 | comment | added | bdutta74 | Am no AVR (or embedded programming) expert, but was wondering if you couldn't make your toggle_led() more efficient by avoiding state, and just do: PORTB ^= 1<<5; Also, I was reading recently in an Atmel document that it is best to avoid calling functions from within an ISR, so might be bettwe to make toggle_led() a macro instead. After-all, it is very small, called at very few places, so the perfect recipe. | |
Jan 8, 2012 at 15:37 | history | edited | 0xakhil | CC BY-SA 3.0 |
added updated code
|
Jan 8, 2012 at 14:27 | history | tweeted | twitter.com/#!/StackElectronix/status/156019152719593474 | ||
Jan 8, 2012 at 13:21 | answer | added | Olin Lathrop | timeline score: 6 | |
Jan 8, 2012 at 12:24 | answer | added | Majenko | timeline score: 7 | |
Jan 8, 2012 at 11:55 | history | asked | 0xakhil | CC BY-SA 3.0 |