strange timer problem


hey people,

i have problem , i'm getting desperate.
let me first explain want do:

i've connected external clock timer 0, channel 0. running in rc compare mode.
also, set tioa0 pin output.

the goal realize frequency divider. value write in rc should divider-value.
so should @ tioa0 pin input-frequency * rc-value.
when watch both signals on oscilloscope see signal @ tioa0 pin bouncing , different results.
its bouncing between right result  (input-frequency * rc-value) , (input-frequency*rc-value - 1).
also, whole program doesn't work more frequencies lower 300hz.

if there questions, feel free ask, great

code: [select]

int ulpin = 2;
int freqteiler = 2;

void externclocksetup() {

  uint32_t xc_tclk, tcclk_xc;

  pmc_set_writeprotect(false);
  pmc_enable_periph_clk((uint32_t)tc0_irqn);

  xc_tclk = tc_bmr_tc0xc0s_tclk0;
  tcclk_xc = tc_cmr_tcclks_xc0;

  tc0->tc_bmr |= xc_tclk;

  tc_configure(tc0, 0, tcclk_xc | tc_cmr_wave | tc_cmr_burst_none | tc_cmr_wavsel_up_rc | tc_cmr_acpc_toggle);// | tc_cmr_cpcstop);// | tc_cmr_cpcdis);

  tc_setrc(tc0, 0, freqteiler);
  tc_start(tc0, 0);
 
}


void setup() {

  serial.begin(9600);
  serial.settimeout(100);
  pinmode(pio_pb26, input);
  pinmode(57, input);
 
  pio_configure(g_apindescription[ulpin].pport,
    g_apindescription[ulpin].ulpintype,
    g_apindescription[ulpin].ulpin,
    g_apindescription[ulpin].ulpinconfiguration);

  externclocksetup();
}


void loop() {
}





Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > strange timer problem


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support