Due Counter Overflow Interrupt Problem


hi guys;
i worked on due little , new arduino community. manage build pulse counter or frequency reader whatever say, 32 b?t counter not enough want.  thought can overflow flag when counter reaches 4294967296 (2^32) therefore carry , ? can count pulses more 4294967296.
the problem cannot manage overflow interrupt. here code far :

code: [select]
#include <duetimer.h>
#define tc_channel_0 0
#define tc_channel_1 1
#define tc_channel_2 2
#define pin_tc0_tclk0_ard (22u)

volatile long unsigned int data[1000];
word = 0;

void setup(){
  pinmode(pin_tc0_tclk2_ard,input);
  pmc_enable_periph_clk(id_tc0);
  serial.begin(9600);
  tc_configure(tc0, tc_channel_2, tc_cmr_tcclks_xc0); 
  tc_start(tc0, tc_channel_2);
  timer4.attachinterrupt(myhandler);
  timer4.start(1000000);
  nvic_enableirq(tc0_irqn);   
}
                                                                                                             
void loop() {

}

void myhandler ()
{
  data[i]= tc_readcv(tc0,tc_channel_2);
  //reg_tc0_bcr = 0x1;
  //if (i == 0){
  serial.print(i), serial.print(" "), serial.println(data[i]);
 
  }
  else{
  serial.print(i), serial.print(" "), serial.println(data[i] - data[i-1]);
 
  }
  i++;
 
}


https://github.com/ivanseidel/duetimer link library. used more accurate delay. information.

so how it? suggestions...
thanks in advance.

i don't have answer trying do?
i'm not sure how timer code works, assume calling handler once second , therefore getting overflow every 71.58 minutes (1 hour, 11 , bit minutes). [the alternative means not overflow on 8000 years!].
if resolution of sampling 1 second, have limit of 4,29ghz (that 2^32 pulses in second). if need more that, try sampling every 10th or 100th of second , applying appropriate multiplier result.
susan


Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > Due Counter Overflow Interrupt Problem


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support