On 4/3/2018 8:42 AM, Nejat Dilek wrote: > > I couldn't find information about that behaviour you described, > possibly attiny85 doesn't have it. It does not look like it. Bummer. You might see if the other 8 pin AVRs have it, as it is relaly useful, if you should decide to make more of these. > I'll possibly stop / start an > internal timer to measure time. I would recommend not starting/stopping. Just set up a free running counter, with the accuracy you need, and then do: static volatile uint8_t ctr; static volatile uin8t_t bit; #define NONE 2 #define ONE 1 #define ZERO 0 ISR() { // !CE interrupt if(ctr < 10) { // less than 100uS ctr = 0; // error } else if (ctr < 20) // 100-200 bit = ZERO; } else if (ctr < 30) // 200-300 bit = ONE; } else ctr = 0; // error } ISR() { //counter 0 compare match, runs at 10uS if(ctr < 255) ctr++; } int main() { uint8_t a; bit = NONE; // set counter to run at CLK/8, and count to 10. This gives 10uS accuracy. ... while(1) { while(bit == NONE) ; a = bit; bit = NONE; switch(a) { // handle bit data, setting b } } } I'd use a enum or a bit field for the bit variable, but I always forget the syntax. JimReceived on 2018-04-03 20:00:02
Archive generated by hypermail 2.2.0.