This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I am using USB HID communication on MSP430f5529 to stream ADC data to PC. I want to trigger ADC conversion every 100us (10kHz) put conversion results in buffer and send data through via USB HID protocol. Whole thing is working except that every 4ms or so timer A0 (that I use to trigger ADC conversion) is skipping (or delaying) one capture/compare interrupt. After skipping one interrupt timer continues normally for 4ms and than does it again.
When I comment out my USB code timer is working perfectly. In the interrupt priority table in documentation it looks like TA0 has greater priority than USB or DMA interrupts.
For USB transfer I am using hidSendDataInBackground function that i found in TI example. That function is implemented using USBHID_sendData function that uses only usbDisableInEndpointInterrupt that should not disable all interrupts (just USB ones):
uint16_t usbDisableInEndpointInterrupt(uint8_t edbIndex)
{
uint16_t state;
state = USBIEPIE & (1 << (edbIndex + 1));
USBIEPIE &= ~(1 << (edbIndex + 1));
return (state);
}
This is relevant part of my code:
Initialization of timer and ISR for timer:
void setupPeriodicTimer()
{
TA0CCR0 = 1250;
TA0CTL = TASSEL_2+MC_1+TACLR; // ACLK, count to CCR0 then roll, clear TAR
TA0CCTL0 = CCIE;
}
#if defined(__TI_COMPILER_VERSION__) || (__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR (void)
#elif defined(__GNUC__) && (__MSP430__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) TIMER0_A0_ISR (void)
#else
#error Compiler not found!
#endif
{
P4OUT ^= BIT1; //toggle the pin just for debug
ADC12CTL0 |= ADC12ENC + ADC12SC;
}
USB communication call:
if (hidSendDataInBackground((uint8_t*)bufferY,MEGA_DATA_LENGTH,
HID0_INTFNUM,0))
{
// Operation probably still open; cancel it
USBHID_abortSend(&w,HID0_INTFNUM);
break;
}
Can anyone help me finding why USB is interfering with timer TA0? Is it possible that USB interrupt routine is so long that it blocks all things for 100us (My clock is at 25Mhz)?
Thank you all in advance.
Thank you Brian for your response.
I will try with that approach and check if I will get more stable sampling intevals.
**Attention** This is a public forum