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
PinIO Class crashes
Re: PinIO Class crashes
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
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
Re: PinIO Class crashes
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.
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.