PinIO Class crashes

Discussion to talk about software related topics only.
Post Reply
barttech
Posts: 135
Joined: Fri Feb 20, 2009 12:59 pm

PinIO Class crashes

Post by barttech »

I'm using the PinIO class, it is handy for most of my work, but I need to use pin TPUCH0 as an output. When I try to use J2[6] I get a TRAP. Does this class work only with certain pins, do I need to init it differently?


StepAddr = 6; // Pin 6 on J2.
J2[StepAddr].function(PIN_GPIO);
J2[StepAddr].clr();
Thanks,
Sam
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: PinIO Class crashes

Post by lgitlitz »

The eTPU pins are not directly connected to the GPIO peripheral. The GPIO is emulated by the eTPU peripheral and works with the pins class but you must first initialize the eTPU. This is all in the eTPU application note:
http://www.netburner.com/downloads/mod5 ... ppNote.zip
Also be aware that GPIO is slower on the eTPU pins then the pins directly connected the GPIO peripheral. If you are doing fast timing I would use one of the specialized eTPU functions or one of the DMA timers with a timer output pin.

-Larry
barttech
Posts: 135
Joined: Fri Feb 20, 2009 12:59 pm

Re: PinIO Class crashes

Post by barttech »

Thanks, I finally got back to this problem. For anyone else who stumbles across this thread, here is what I did:

if ((StepAddr>=5)&&(StepAddr<=20)){ // It is a eTPU channel.
int chan; // Convert pin number to eTPU channel.
if (StepAddr%2==0)
chan = StepAddr - 6;
else
chan = StepAddr - 4;
eTPUInit(); // Initialize eTPU pins for GPIO
eTPUFunctionGPIO(chan);
}
else
J2[StepAddr].function(PIN_GPIO);
J2[StepAddr].clr(); // Now can use the standard pin IO class.
Post Reply