HI,all.
I have a wired problem using C6713'timer and GPIO. I would appreciate for any help!
What I want to do is to change a GPIO's value every period of T . That is to say , at first, GPIO is set value 0 ,and after a certain period T ,the same GPIO is set 1 . Then after another T , GPIO 0 again ,and so on.
My idea : I use a timer to do this. when timer reaches the period T, it goes into the interrupt function , in which GPIO is set 0 or 1 alternatively .
here is the configuration:
1. /*set gpio*/
hGpio = GPIO_open(GPIO_DEV0,GPIO_OPEN_RESET);
GPIO_reset(hGpio);
GPIO_pinEnable(hGpio,GPIO_PIN12);
GPIO_pinDirection(hGpio,GPIO_PIN12,GPIO_OUTPUT);
2. /*config the timer and enable the timer interrupt*/ hTimer1 = TIMER_open(TIMER_DEV1,TIMER_OPEN_RESET); TimerEventId = TIMER_getEventId(hTimer1); TIMER_configArgs(hTimer1, 0x00000201, /* use internal clock*/ T , /* set period T */ 0x00000000 ); IRQ_map(TimerEventId, 14); IRQ_enable(TimerEventId); 3.while(1); //wait the timer into the interrupt 4./*set the GPIO value in the interrupt function*/ interrupt void c_int14(void) {GPIO_pinWrite(hGpio,GPIO_PIN12,value); value=!value; //value is either 0 or 1 }
PROBLEM: I can see the GPIO is changed every T period. However, I also find that the GPIO is shaking . That is to say , the moment GPIO is set the opposite value is different for each round (period T).(about several ns).Is it caused by the uncerntain time DSP corresponds to the timer interrupt?I don’t know why.oscilloscope, 1.From the 2.I want the GPIO is set at the same time for each period exactly. I don’t hope that in this round the GPIO is set at NT+t0,the GPIO is set at NT+ t1 .Is there another method to achieve it?