Tool/software: Code Composer Studio
Hello,
I am trying to detect a rising edge from an input signal using the Tiva C, I am trying to do this using loops.
I am running into a problem with the variables for the loop, I am trying to keep the input pin on read for loop by anding it with a binary value, however, I am not sure if I am doing this correctly.
These are the variables that I am using:
#define PIND 0x00000010 #define SIGANLIN_PIN GPIO_PIN_4
And here is the loop that I am calling to detect the rising and falling edge:
if (pulsevalue != 0) { UARTprintf("Pulses detected\n"); //this will enable the pulses to be read SafteyCountdown(); //Will blink the LED to show the program will start running while(1) { last = 0; now = PIND & (1<<SIGNALIN_PIN); if (now != last) { if (now > 0){ bpm++;//rising edge, do something GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3 | GPIO_PIN_0, GPIO_PIN_3); //Need to output to the high pin } else { //need to output to the low pin GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_3, GPIO_PIN_0); } last = now; //remember state for next pass } //end of now != last } //end of while UARTprintf("Interrupt Conducted\n"); // InterruptEnable(); } else { //This will allow the program to be run the same way if there are no pulses present UARTprintf("Pulses not detected\n"); SafteyCountdown(); //Will blink the LED to show the program will start running // InterruptEnable(); while(1) { now = PIND & (1<<SIGNALIN_PIN); if (now != last) { if (now > 0){ bpm++;//rising edge, do something GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3 | GPIO_PIN_0, GPIO_PIN_3); //Need to output to the high pin } else { //Need to output to low pin GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_3, GPIO_PIN_0); } } last = now; //remember state for next pass } //end of now != last } //end of while UARTprintf("Interrupt Conducted\n");