Trouble with RB compare on timers

Hello

I'm having trouble getting TIOB6 to work on PC26. I noticed there was a small voltage on the pin which //PIO_Configure(PIOA,PIO_OUTPUT_0,PIO_PA29,PIO_DEFAULT ) ; solves but regardless the pin still isn't set correctly. TIOA6 on PC25 works fine.

volatile int freq = 50000;

void setup(){

pmc_set_writeprotect(false);

pmc_enable_periph_clk((uint32_t)TC6_IRQn);

TC_Configure(TC2, 0,TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK1|TC_CMR_ACPA_CLEAR|TC_CMR_ACPC_SET|TC_CMR_BCPB_CLEAR|TC_CMR_BCPC_SET);

TC_SetRA(TC2, 0, (freq/3));

TC_SetRB(TC2, 0, (freq/2));

TC_SetRC(TC2, 0, freq);

PIO_Configure(PIOC,PIO_PERIPH_B,PIO_PC25B_TIOA6,PIO_DEFAULT);

PIO_Configure(PIOC,PIO_PERIPH_B,PIO_PC26B_TIOB6,PIO_DEFAULT);

//PIO_Configure(PIOA,PIO_OUTPUT_0,PIO_PA29,PIO_DEFAULT ) ;

TC_Start(TC2, 0);

}

void loop(){
}

Any help much appreciated, Thanks Rufe0

Got the same problem with PD7 TIOA8 & PD8 TIOB8 except its A that wont work on that one.

Scratch that it is B that wont work, had my wires crossed, so I tried B on TC7 and TC0, all not working.

Rufe0:
Hello

I'm having trouble getting TIOB6 to work on PC26. I noticed there was a small voltage on the pin which //PIO_Configure(PIOA,PIO_OUTPUT_0,PIO_PA29,PIO_DEFAULT ) ; solves but regardless the pin still isn't set correctly. TIOA6 on PC25 works fine.

volatile int freq = 50000;

void setup(){

pmc_set_writeprotect(false);

pmc_enable_periph_clk((uint32_t)TC6_IRQn);

TC_Configure(TC2, 0,TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK1|TC_CMR_ACPA_CLEAR|TC_CMR_ACPC_SET|TC_CMR_BCPB_CLEAR|TC_CMR_BCPC_SET);

TC_SetRA(TC2, 0, (freq/3));

TC_SetRB(TC2, 0, (freq/2));

TC_SetRC(TC2, 0, freq);

PIO_Configure(PIOC,PIO_PERIPH_B,PIO_PC25B_TIOA6,PIO_DEFAULT);

PIO_Configure(PIOC,PIO_PERIPH_B,PIO_PC26B_TIOB6,PIO_DEFAULT);

//PIO_Configure(PIOA,PIO_OUTPUT_0,PIO_PA29,PIO_DEFAULT ) ;  uncomment this line ??

TC_Start(TC2, 0);

}

void loop(){
}




Any help much appreciated, Thanks Rufe0

According to note on schematic pins C26 and A29 are physically connected , you probably need to configure both same to make them physically work together. Uncomment A29 configuration? ( See code )

Vaclav:
According to note on schematic pins C26 and A29 are physically connected , you probably need to configure both same to make them physically work together. Uncomment A29 configuration? ( See code )

Hello

Yep I tried that... there was a small voltage on the pin which that solved but it still didn't work. Besides that pins B27 and D8 aren't connected to another pin and those have the same problem. There must be something fundamentally wrong with how I'm doing it. I've tried just B on it's own without A.

Rufe0:
Hello

Yep I tried that... there was a small voltage on the pin which that solved but it still didn't work. Besides that pins B27 and D8 aren't connected to another pin and those have the same problem. There must be something fundamentally wrong with how I'm doing it. I've tried just B on it's own without A.

You may have to check the actual pin hardware in manual.
I recall that there are some A / B options on I/O pins identifying the source.
But it did not get into details why is that.

It seems odd to physically connect pins together.

And for what purpose?

Let's say you set the output high on one pin without making the other pin "open / high impedance".
It just cannot work, the pins outputs are in parallel as far as the outside world in concerned.

Here is a idea why these pins are wired together.
Let's say you want to physically verify that a pin is set.
Set mode of one of the pair to output and the other pin mode as input (pull up).
Set the first (output) pin to low and read the second (input) pin. Neat.

Using different modes is actually application of my initial idea to make sure one of the pins is in high impedance. I just did not carry it far enough.

The bottom line - configuring both pins as output won't work unless they are set same.

Go on. Surely all controllers have a method of reading a GPIO pin's state. As an input or just reading the state of the output latch. e.g. PING, PORTG on an AVR.

I do agree that you might want to read a pin that is being used for an Alternate hardware function. But there is nothing to stop you physically connecting two pins on the Due.

David.

david_prentice:
Go on. Surely all controllers have a method of reading a GPIO pin's state. As an input or just reading the state of the output latch. e.g. PING, PORTG on an AVR.

I do agree that you might want to read a pin that is being used for an Alternate hardware function. But there is nothing to stop you physically connecting two pins on the Due.

David.

nothing to stop you physically connecting two pins on the Due.

or read the OP so you have an idea what I was talking about

Well I figured it out, TIOB is by default an external trigger input which means it cannot be an output.

To resolve this you need to set any of the other external trigger inputs.

TC_Configure(TC0,0,TC_CMR_EEVT_XC0);

or

TC0->TC_CHANNEL[0].TC_CMR= TC_CMR_EEVT_XC0;

Rufe0:
Well I figured it out, TIOB is by default an external trigger input which means it cannot be an output.

To resolve this you need to set any of the other external trigger inputs.

TC_Configure(TC0,0,TC_CMR_EEVT_XC0);

or

TC0->TC_CHANNEL[0].TC_CMR= TC_CMR_EEVT_XC0;

Which is similar conclusion I came up with - the pins wired together ( on PCB - to be precise and avoid #7 remark that "you can wire any pins together" ) cannot be both output.