We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have the lpc3131 embedded artists board and I am working on a USB driver. I first converted the Keil example code to IAR code and got the USB working. I then tried to port it over to a different syntax and for some reason the following code does not reset the ep_QH (end point queue head) to make dQH (device queue head) values zero:
DQH_T* const ep_QH = (DQH_T*)DQH_BASE;
//memset fills the first n bytes of the memory area //pointed to by s with the constant byte c. //void *memset(void *s, int c, size_t n);
/* Zero out the Endpoint queue heads */ memset((void*)ep_QH, 0, EP_NUM_MAX * sizeof(DQH_T));
/* dQH Queue Head */ typedef volatile struct { Int32U cap; Int32U curr_dTD; Int32U next_dTD; Int32U total_bytes; Int32U buffer0; Int32U buffer1; Int32U buffer2; Int32U buffer3; Int32U buffer4; Int32U reserved; Int32U setup[2]; Int32U gap[4]; } DQH_T;
//Here's the memset function: #define _DLIB_STRING_SKIP_INLINE_MEMSET #pragma inline void * memset(void * _D, int _C, size_t _N) { __aeabi_memset(_D, _N, _C); return _D; }
It goes into the function and passes the correct parameters but it doesn't seem to change the value of dQH to zero. Anyone know why this is happening or a work around.
Just more thing - any reason for memset() of 16 bytes? Is that the only part of the *ep_QH entry you want cleared?
It will only clear the fields cap, curr_dTD, next_dTD and total_bytes. Not to many queues, lists etc would like some outsider to clear private fields. The next_dTD field might possibly chain the entries in the queue in which case a clear of it would break the queue.
Thank you so much for all the help. I realized the problem was that another programmer had commented out my SDRAM initialization function and so I was trying to read an address that was not memory mapped. My solution was to just change the address I was selecting to an internal onchip SRAM memory location instead.
Thanks again.