-->
Page 1 of 2

Timer0 interrupt not cycle accurate?

PostPosted: Sat Sep 19, 2015 5:21 am
by NardJ
I am testing the accuracy of timer0 in term of cycles (to output vga signal).
I have tested this with the code below which outputs (to the serial monitor) the number of cycles between interrupt calls. However this number of cycles between interrupts varies. Is my code wrong or perhaps another interrupt (Timer1 maybe, but how to turn it off?) messing with TImer0?

Code: Select all#define MAXI 30
uint32_t d[MAXI];
int c=0;
void setup() {
  Serial.begin(115200);
  Serial.println("Setup");
  noInterrupts();
  timer0_isr_init();
  timer0_attachInterrupt(itr);
  timer0_write(ESP.getCycleCount() +80005000);
  interrupts();
}
void itr (void){
  timer0_write(ESP.getCycleCount()+80000000);
  d[c]=ESP.getCycleCount();
  c++;
  if (c==MAXI){
    for (int i=0;i<MAXI-1;i++) Serial.println(d[i+1]-d[i]);
    c=0;
  }
}

A sample of the output is 80000445, 80000440, 80000441, 80000495, 80000462, 80000476, 80000440, 80000502, 80000441, 80000440, 80000442. Each number meaning the number of cycles passed between interrupts.

Re: Timer0 interrupt not cycle accurate?

PostPosted: Wed Aug 03, 2016 9:01 am
by kissste
Hello,

have you managed to make any progress on the ESP8266 to VGA output?

If so, please share it with us. I'm interested in ESP8266 to VGA or ESP8266 to LVDS (1-channel 6-bit).

Thank you.

Re: Timer0 interrupt not cycle accurate?

PostPosted: Wed Aug 03, 2016 10:03 am
by martinayotte
kissste wrote:have you managed to make any progress on the ESP8266 to VGA output?

If so, please share it with us. I'm interested in ESP8266 to VGA or ESP8266 to LVDS (1-channel 6-bit).


What are you talking about ?
There is no way that an ESP could generate any VGA or LVDS signal ...

Re: Timer0 interrupt not cycle accurate?

PostPosted: Wed Aug 03, 2016 11:52 am
by schufti
I wouldn't be so negative. An ATmega328 with 18.something MHz (little out of specs) crystal coded in assembler is able to do even PAL color bars.
A simple fbas b/w display is available as lib for UNO...

So maybe some heavily optimized code with wifi disabled could do astonishing things?