Page 1 of 1
Need delay after sdStart() or I get garbage
Posted: Mon Jan 31, 2011 8:16 am
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!
Re: Need delay after sdStart() or I get garbage
Posted: Mon Jan 31, 2011 9:03 am
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
Re: Need delay after sdStart() or I get garbage
Posted: Mon Jan 31, 2011 9:14 am
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.
Re: Need delay after sdStart() or I get garbage
Posted: Mon Jan 31, 2011 9:58 am
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
Re: Need delay after sdStart() or I get garbage
Posted: Mon Jan 31, 2011 10:09 am
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!
Re: Need delay after sdStart() or I get garbage
Posted: Tue Feb 01, 2011 2:06 am
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.
Re: Need delay after sdStart() or I get garbage
Posted: Tue Feb 01, 2011 2:11 am
by JetForMe
Heh. I may or may not have been to a few launches, or written some space-related iPhone app...