Simple USB Read with callback question

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

Posts: 8
Joined: Thu Jul 28, 2011 4:14 pm

Simple USB Read with callback question

Fri Aug 12, 2011 4:59 pm

I have a very simple question about USB reads with call backs.

I want to set up a read to a buffer then wait until the transfer is complete before using the data in the buffer. This is how I am currently doing it:

volatile unsigned char readArrayLock = 0;

//USB read callback
void readNextDataArrayCallback(void *pArg, unsigned char status, unsigned int transfered, unsigned int remaining){
readArrayLock = 0;

//To read the usb data
readArrayLock = ! USBD_Read(0x2, g_pucDataArray, g_iDataPacketSize, (TransferCallback)readNextDataArrayCallback, 0);
// waiting
while (readArrayLocked);
//Then use data

The problem I am having is that the interupt never seems to be called whilst in the while loop. If i comment out the while loop the interupt is called.

How can I fix this? Or is there a better method for achiving the same thing?


Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest