I'm working with the C2000 F28377xS device and want to implement a switch such that when a voltage is applied to a GPIO21 pin, two ePWM GPIO pins will output a duty cycle based on the input in the ADCINA0 pin.
I currently have the ADCINA0 pin and the two ePWM GPIO pins configured and working properly. I however want to add a single pole double throw switch to give myself more control over the PWMs & ADC pins.
How do I modify the GPIO21 pin to be able to read ADC inputs? How do I account for debouching from the switch? I believe that it is good practice to have code such that after a signal has been high for about 10 clock cycles, it can be concluded that the switch state is good, and that the corresponding block of code can be executed.
"//GPIO setup: Input qualification?
void Gpio_Setup(void){
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO21 = 0; //enable pullup on GPIO21
GpioCtrlRegs.GPAQSEL2.bit.GPIO21 = 0; //Synch to SYSCLKOUT
GpioCtrlRegs.GPAGMUX2.bit.GPIO21 = 0; //GPIO21 = GPIO21
GpioCtrlRegs.GPADIR.bit.GPIO21 = 0;
} "