Other Parts Discussed in Thread: CC1310
Tool/software:
Hello!
I have this sensor that is sending pulses of 0 and 1's to CC1310 DIO7. I have to measure the time that each 0 or 1 stays high or low so I can translate it inside the code. The sensor I'm using is:
Each Lambda is about 330~360 useconds. So to be 0 it needs to be low for around 340useconds and then stay double the time at high. The oposite is for 1. The Pilot is 27 lambdas (around 9,7 ms) at low. In order to translate the packet into 0 and 1's I need to measure the time of each pulse. I've tried to measure it with gpiointerrupt, pinInterrupt and GPTimer but it sometimes give me inconsistent values. This is the code I'm using:
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
/* Call driver init functions */
GPIO_init();
/* Configure the LED and button pins */
GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(Board_GPIO_BUTTON0, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING);
/* Turn on user LED */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
/* install Button callback */
GPIO_setCallback(Board_GPIO_BUTTON0, gpioButtonFxn0);
/* Enable interrupts */
GPIO_enableInt(Board_GPIO_BUTTON0);
/*
* If more than one input pin is available for your device, interrupts
* will be enabled on Board_GPIO_BUTTON1.
*/
if (Board_GPIO_BUTTON0 != Board_GPIO_BUTTON1) {
/* Configure BUTTON1 pin */
GPIO_setConfig(Board_GPIO_BUTTON1, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING);
/* Install Button callback */
GPIO_setCallback(Board_GPIO_BUTTON1, gpioButtonFxn1);
GPIO_enableInt(Board_GPIO_BUTTON1);
}
return (NULL);
}
* ======== gpioButtonFxn0 ========
* Callback function for the GPIO interrupt on Board_GPIO_BUTTON0.
*/
void gpioButtonFxn0(uint_least8_t index)
{
ticks = (Clock_getTicks());
buffer[i] = ticks;
buffer1[i] = ticks - savedTicks;
i++;
if(i>=50)
i = 0;
savedTicks = ticks;
/* Clear the GPIO interrupt and toggle an LED */
//GPIO_toggle(Board_GPIO_LED0);
}
I was using Clock_getTicks() each time an interrupt occurs and measure the time but without success. I was thinking that the interrupt is entering two times in a row or the system is taking to much time (or overhead) and I like I said entering the same interrupt back-to-back. Any ideias how to fix it? Is there a possibility that the system is entering sleep for too much and taking a lot of time to wake up?
As you can see at lines [0] and [1], 3 and 12 ticks are not what I'm expecting.