Need delay after sdStart() or I get garbage

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Need delay after sdStart() or I get garbage

Post by JetForMe »

I created a new HAL and board for an ATmega644A. It seems to work fine, but when I try to output bytes to the serial port, if I don't introduce a delay between the sdStart() call and the first write, it's all garbage. After a sufficient delay, it works fine.

Even with the delay, however, it always seems to output one garbage character.

I based my port off the Olimex ATmega128 in the 2.2.x branch.

Any suggestions? Thanks!
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Need delay after sdStart() or I get garbage

Post by Giovanni »

Hi,

What kind of delay do you have to insert?

Anyway, I have to run some tests about this issue, thanks for reporting.

Giovanni
JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Need delay after sdStart() or I get garbage

Post by JetForMe »

The following works:

Code: Select all

   sdStart(&SD2, NULL);
   chThdSleep(35);
   sdWrite(&SD2, "Hello\n", 6);


Passing a value of 1 does not, but I haven't worked out the minimum delay required.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Need delay after sdStart() or I get garbage

Post by Giovanni »

It is possible that the problem happens during the switch of the TX pin from GPIO to USART. The GPIO pin should be programmed to be an output driving a logic one during initialization and the logic one should last at least one frame time in order for the receiver to synchronize.

Try to put the delay before sdStart(), if the problem still disappears then it is a synchronization problem else it is an initialization problem.

Giovanni
JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Need delay after sdStart() or I get garbage

Post by JetForMe »

Sure enough, if I set the GPIOs to outputs and set them to 1 (on the TX pins only), I can remove the delay and have no garbage.

Thanks!
ianmga
Posts: 42
Joined: Fri Jan 28, 2011 1:11 am

Re: Need delay after sdStart() or I get garbage

Post by ianmga »

JetForMe wrote:I created a new HAL and board for an ATmega644A. It seems to work fine, but when I try to output bytes to the serial port, if I don't introduce a delay between the sdStart() call and the first write, it's all garbage. After a sufficient delay, it works fine.

Even with the delay, however, it always seems to output one garbage character.

I based my port off the Olimex ATmega128 in the 2.2.x branch.

Any suggestions? Thanks!


Hey aren't you one of the Space Tweeps? The handle sounds familiar.
JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Need delay after sdStart() or I get garbage

Post by JetForMe »

Heh. I may or may not have been to a few launches, or written some space-related iPhone app...
Post Reply