Go Down

Topic: Timer usage without interrupts (Read 867 times) previous topic - next topic


I want to accurately set the output timing of data by detecting the timer period flag , CPCS in TC_SR, but I'm having no luck. The code seems to run as if the timing controls were not in place, so I suspect the flag is permanently set:

Code: [Select]

//in setup

  PIOC->PIO_OWER = 0X1E; //data out on C1-4
  REG_PIOB_PDR = 1<<25;    // disable pio then enable peripheral
  REG_PIOB_ABSR = 1<<25;   // select peripheral B
  REG_TC0_WPMR = 0x54494D00; //enable write to registers
  REG_TC0_CMR0 = 0x0009C400; //set channel mode
  REG_TC0_RC0 = symps; //counter period
  REG_TC0_RA0 = 10;  //pwm value
  REG_TC0_CCR0 = 0b101;    // start counter

(Most code was shamelessly lifted from other parts of this forum!)

Code: [Select]

//Main loop

    while (!REG_TC0_SR0 & 0x10); //check for end of period CPCS
    TC_GetStatus(TC1, 0); //clear status reg
     PIOC->PIO_ODSR = data1; //output data

    while (!REG_TC0_SR0 & 0x10); //repeat ad nauseam
     PIOC->PIO_ODSR = data2;

I've also tried detecting other flags such as MT1OA. Anyone any ideas, please?


And the solution is... OK, use of brackets in the while loop i.e. more needed.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131