at91sam3u1 vs at91sam3u4 problems

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

thereza
Posts: 6
Joined: Sat Jul 30, 2011 12:50 pm

at91sam3u1 vs at91sam3u4 problems

Sat Jul 30, 2011 1:08 pm

I've been trying to compile the sample project basic-sdmmc-test-project-at91sam3u-ek (sam3u4) on a sam3u1 and I've hit a wall. It seems to work, but after a bit, it seems to get stuck on the SD Card init routine. I'm sure there's a more complex problem that I'm missing. Here are some comments and things I've done/tried..

. modified linker so it treats the two ram segments as one
. updated the board.h definition file to represent my hardware
. removed the slow clock init as I don't have a 32khz xtal

The code appears to work, but it gets stuck just after it tries to go into high speed mode. If I try to make small changes to the code (such as disabling high speed mode or 4-bit mode or turning off the USB interface) then it hard-faults on the clock init. If I step through the code, however, it gets past it, but I still experience the same problem.

In looking at the HSMCI_SR status register, when most commands are sent on the MCI bus (DMA enabled) and the code recognizes as a sucessfull transfer, the flags [UNDERRUN, OVERRRUN, TXRDY, CMDRDY, NOTBUSY] are set. When it gets "stuck" it just returns the flags [FIFO EMPTY, TXRDY, CMDRDY]. After some seconds, the flags match the sucessfull state but the code does not continue.

The fact that small changes to the code result in a hard fault is annoying. I've also not been able to find any sample code or the examples ported to the 3u1. Any help here would be greatly appreciated. If I can't figure it out, I'm going to try to switch to the 3u4 to see if that solves my problems.

It doesn't help that the example code is unnecessarily complex :/
thereza
Posts: 6
Joined: Sat Jul 30, 2011 12:50 pm

Re: at91sam3u1 vs at91sam3u4 problems

Sun Jul 31, 2011 12:16 am

I made a big breakthrough. I'm not sure why exactly it would hard fault when i touched the code, but it seems that i just need to add some wait states to the code that changed the wait states for the embedded flash controller. Not even sure why it's required, but it seems to be. In any case, it seemed the critical thing was to check for FRDY after setting EFC_FMR0 before doing anything else.

Also, according to the datasheet, there are two EFC (emmbeded flash controllers) but only one seems to do anything, and the second one's definition was commented out in the at91sam3u1.h file.

I modified the code to this (if others are stuck in my shoes)

/* Set 3 WS for Embedded Flash Access
************************************/
while( !(AT91C_BASE_EFC0->EFC_FSR & AT91C_EFC_FRDY)); //wait for FRDY flag to be set
if ( (AT91C_BASE_EFC0->EFC_FSR) & FLOCKE) while(1); //trap locking region violation
if ( AT91C_BASE_EFC0->EFC_FSR & FCMDE) while(1); //trap bad keyword violation
AT91C_BASE_EFC0->EFC_FMR = AT91C_EFC_FWS_3WS;
while( !(AT91C_BASE_EFC0->EFC_FSR & AT91C_EFC_FRDY)); //wait for FRDY flag to be set
if ( (AT91C_BASE_EFC0->EFC_FSR) & FLOCKE) while(1); //trap locking region violation
if ( AT91C_BASE_EFC0->EFC_FSR & FCMDE) while(1); //trap bad keyword violation

which seems like overkill, but it solved my initial problem. Also, now that I can tweak the rest of the code, it seemed as if setting the bus to 4-bits caused my grief. I'm going to see if something not hooked up right.

Additionally, the code to switch to a high-speed (25Mhz) bus failed for some reason..

Now to figure out the USB portion of the code.

reza
thereza
Posts: 6
Joined: Sat Jul 30, 2011 12:50 pm

Re: at91sam3u1 vs at91sam3u4 problems

Tue Aug 02, 2011 9:05 am

I just noticed I posted the original post a couple times. Kept hitting post but nothing would happen - guess something did.

I just wanted to add that I contacted atmel and they have the at91sam3u1 and 3u2 versions of the projects. They didn't test them as the linker script still doesn't allow the script to compile, but email me and i can send you the updated file if needed.
bobpilati
Posts: 2
Joined: Mon Jul 25, 2011 9:27 pm

Re: at91sam3u1 vs at91sam3u4 problems

Fri Aug 05, 2011 4:26 am

Hello,

Since I've had stability issues with running code from Flash aswell on a SAM3U, I'll post it here. Changing the Flash wait state on boot up made the SAM3U fail less than before for me, but occasionally it would still fail and give a HardFault.

The solution (or rather, workaround) that I came up with was to move the LowLevelInit() function and all the functions it calls to SRAM before calling it (this includes setting up the clocks, PLLs, etc).

In the SAM3U manual, it says not to change the Embedded Flash registers while running code from Flash, so I'm guessing this had something to do with my stability issues.

Best Regards.
thereza
Posts: 6
Joined: Sat Jul 30, 2011 12:50 pm

Re: at91sam3u1 vs at91sam3u4 problems

Fri Aug 05, 2011 6:00 am

From my understanding, the simplest way to move code to SRAM is by using a special directive in IAR -- how did you do it?

I've not had a fault since I wait on that busy bit -- have you tried that?

Reza

p.s. I was told that they would be posting the updated sample code and drivers (window 7) at my request which is nice. I suppose it's true what they say -- you never know till you ask.

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 4 guests