Timeline for More speed from ATMEGA328 Internal Clock
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 12, 2017 at 21:23 | comment | added | Jot | I'm very sorry, I made two mistakes. You are right. I have tested it in software and _delay_us(0.5) results in a delay of 0.506 µs (according to a software approximation. Thank you. I learned something new. | |
| May 12, 2017 at 7:57 | comment | added | Edgar Bonet |
@Jot: You wrote: “The 'val' should shift the 0x80 to the right”. Shifting 0x80 to the right works also, although it produces slightly less efficient code, as it requires an extra register to hold the bit mask. Shifting val to the left, with the fixed mask 0x80, allows the compiler to use a bit-test instruction (sbrs) and never store the bit mask. “It is not possible to delay ‘0.5’ only unsigned long numbers”. This is incorrect. Delaying by 0.5 µs (or even 0.125 µs, given an 8 MHz clock) works perfectly well with _delay_us() (not with delayMicroseconds()). Try it!
|
|
| May 11, 2017 at 23:37 | vote | accept | Tanner Ewing | ||
| May 11, 2017 at 22:08 | comment | added | Jot | When the SPI bus is not possible, then this is the way to do it. Arduino has bitSet() and bitClear macros which result into the same I/O bit instructions. The 'val' should shift the 0x80 to the right. It is not possible to delay "0.5" only unsigned long numbers, and delayMicroseconds() could be used, or the delay by clock cycles (I forgot the name). | |
| May 11, 2017 at 19:41 | history | edited | Edgar Bonet | CC BY-SA 3.0 |
+ tentative implementation.
|
| May 11, 2017 at 19:13 | history | answered | Edgar Bonet | CC BY-SA 3.0 |