Hello
I'm working with the TM4C1294XL evaluation board. I'm connecting the waveform generator to the PD0 of the board. So basically my task is to calculate the turn-on time of the received duty cycle. For doing so, PD0 is configured as follows
void GPIOInit() { // // Enable the GPIOD peripheral // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // // Wait for the GPIOD module to be ready. // while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD)) { } // // Register the port-level interrupt handler. This handler is the first // level interrupt handler for all the pin interrupts. // GPIOIntRegister(GPIO_PORTD_BASE, GPIOD_Handler); // // Initialize the GPIO pin configuration. // // Set pins 0 as input, SW controlled. // GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_0); // // Make pins 0 rising edge triggered interrupts. // GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_BOTH_EDGES); GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0,0); i32Val = GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_0); UARTprintf("\n\nInitial value of PD0 = '%d'",i32Val); // // Enable the pin interrupts. // GPIOIntEnable(GPIO_PORTD_BASE, GPIO_INT_PIN_0); }
Now the point is, in the ISR I want to detect when exactly the rising edge or falling edge arrives so that I can capture the timer counter value exactly when the falling edge arrives. Initially, I thought that if zero received at the pin PD0 then the falling edge is received and if one is received then it should be the rising edge but I'm not sure about this.The which I have written is as follows,
void GPIOD_Handler(void) { uint32_t status; status = GPIOIntStatus(GPIO_PORTD_BASE,true); // // Clear the interrupt. // GPIOIntClear(GPIO_PORTD_BASE, status); check_edge = GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_0); if(check_edge == 0) //positive edge detected { UARTprintf("\n\nPositive edge DETECTED!!"); i32Val = GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_0); UARTprintf("\nPositive Edge value of PD0 = '%d'",i32Val); } else if(check_edge == 1) //negative edge detected { flag = true; UARTprintf("\n\nNegative edge DETECTED!!"); i32Val = GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_0); UARTprintf("\nNegative Edge value of PD0 = '%d'",i32Val); } GPIOIntDisable(GPIO_PORTD_BASE, GPIO_INT_PIN_0); }
Also, I'm attaching the output where some random 0 snd 1's are received!.
So I wanted to be sure in the ISR that whether falling or rising edge received.
Any help or suggestion will be really appreciated!
Regards,
Omkar Dixit