Hi Folks!
I have a quite weird issue on my Xplained Ultra board. The thing is something that is nonsense and I would ask You to check it on your own one!
I am using Atmel Studio 7.0. (ver. 7.0.1188) Compiler is GCC version 5.3.1.
The tool used is EDBG. No optimization is applied to the code.
In short words: the 'USB Device CDC' example in the 'AS Software Package 1.5' works well until it applies SDRAM writes... then it makes the program to be frozen after some time when doing the 'test' with it.
---
In details:
To check the thing:
- Download the "SAMV71-XULT Atmel Studio Software Package 1.5". And open example located at .\examples_usb\device_examples\usb_cdc .
- Since I have troubles with CDC when the code is located on flash, I use the 'sram' linker script and the flash is erased. (Though, running from flash it is the same faulty as from SRAM.)
- Make Tiny modifications to the source code:
- in main.c just before 'USBD_Connect();', add these two lines to enable the SDRAM:
_SetupMemoryRegion();
BOARD_ConfigureSdram(); - in main.c, _SendText() function, replace 'while (!txDoneFlag);' with 'while (!txDoneFlag) SDRAM_write();'
- Implement 'SDRAM_Write()' as:
void SDRAM_write()
{
uint32_t* p = (uint32_t*)SDRAM_CS_ADDR;
for(int i=0; i<8; i++) *(p++) = 0xffff0000; //or any value...
}
- in main.c just before 'USBD_Connect();', add these two lines to enable the SDRAM:
- Open the EDBG Virtual COM port with a terminal like PuTTY.
- Connect the board to the PC through the USB, then run the modified code. A new device appears and some COM port is assigned to it. (Check in device manager or such.)
- Open this new COM port (CDC) with another terminal.
- Press 't' key some times on the EDBG Virtual COM port's terminal. After some tries the board is frozen (infinite loop waiting for and USB (endpoint) to be ready) and it does not do anything more.
If You comment out the '*(p++) = 0xffff0000;' from the code, so no writes are made to the SDRAM, it works without error. At least for me...
---
Please confirm that this fault is present on other board pieces too, not only on mine!
Any thought on this kind of error is welcome since I am not able to imagine anything that should work like this.
(I have spent 1 full month yet to discover such 'bug' in my own project, where the same was present: USB (host) gets error when I use (write) the SDRAM quite often. Lowering the write frequency may lower the risk of the fault, but this is not so simple... it's very complicated. My project's USB and SDRAM code has been ported to the Xplained Ultra board and it shows the same error, but even more frequently! And only depends on the SDRAM write access. Oh, my god... what is this???)
Thank You!
Zoltan