Pages: [1]   Go Down
Author Topic: Timer usage without interrupts  (Read 381 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
//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:
//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
    dummy=REG_TC0_SR0;
     PIOC->PIO_ODSR = data2;
etc.

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

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: