Hello
I am going to implement a USB Device using LPC1768 and I need the isochronous transfer type for my application. To this purpose I studied the keil's USBAudio example. It is written in the datasheet of the MCU that the frame interrupt is generated every 1 ms, but this interrupt occurs very much more than one time in 1 ms in USBAudio. Where am I wrong?
The OSC of LPC1768 is unstable - Place the crystal near to the XTAL1/2 pins. OR The frequency of USB clock (PLL) is wrong.
The USB SIE on LPC1768 generates FRAME interrupt timing using a dedicated timer and USB clock. And then, you’ll see it without USB connection. When SOF comes from host, the SIE makes the timer synchronized to the SOF timing by DPLL (Digital PLL). This circuitry is known as SOF recovery, which provides steady SOF interval even when missing SOF occurs by communication error.
In this reason, FRAME timing is affected by the quality and accuracy of USB clock so much
Tsuneo
Thank you Tsuneo.
Sorry Tsuneo. I checked the crystal and It's near to XTAL pins (about 1 cm). The clock configuration of the system_LPC17xx.c (configuration wizard tab) is as follows (the crystal is 12 MHz):
PLL1 Configuaration (USB PLL) Checked MSEL: PLL Multiplier Selection 4 PSEL: PLL Divider Selection 2 USBSEL: Divide Value for USB Clock from PLL1 0
I added the following code in the beginning of the USB_SOF_Event to create pulses on the DAC in each SOF event:
int flag; void USB_SOF_Event (void) { LPC_DAC->DACR = (flag ? 1023 << 6 : 0); flag ^= 1; }
but the frequency of the generated wave is high (order of hunderd KHz). If I place such code in the beginning of the endpoint event witch is handled through DMA the frequency of the generated square wave is as expected. Is the problem still relative to the USB clock?
> but the frequency of the generated wave is high (order of hunderd KHz).
Sound like the FRAME interrupt flag is not cleared by the stack.
Add this line to your USB_SOF_Event()
LPC_USB->USBDevIntClr = FRAME_INT; // clear FRAME interrupt flag
The problem is solved. I appreciate your help.