Go Down

Topic: Trouble with RB compare on timers (Read 1 time) previous topic - next topic

Rufe0

Nov 01, 2015, 02:18 pm Last Edit: Nov 05, 2015, 01:22 pm by 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.
Code: [Select]
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

Rufe0

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

Rufe0

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

Vaclav

#3
Nov 05, 2015, 01:27 am Last Edit: Nov 05, 2015, 01:29 am by Vaclav
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.
Code: [Select]
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 ) ;  [color=red]uncomment this line ??[/color]

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 )

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 )

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.

Vaclav

#5
Nov 05, 2015, 03:42 pm Last Edit: Nov 05, 2015, 03:42 pm by Vaclav
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.

Vaclav

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.



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.

Vaclav

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

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;

Vaclav

#10
Nov 08, 2015, 05:10 am Last Edit: Nov 08, 2015, 05:13 am by Vaclav
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.

Go Up