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!
Need delay after sdStart() or I get garbage
Moderators: RoccoMarco, lbednarz, tfAteba
- 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
Hi,
What kind of delay do you have to insert?
Anyway, I have to run some tests about this issue, thanks for reporting.
Giovanni
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
The following works:
Passing a value of 1 does not, but I haven't worked out the minimum delay required.
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.
- 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
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
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
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!
Thanks!
Re: Need delay after sdStart() or I get garbage
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
Heh. I may or may not have been to a few launches, or written some space-related iPhone app...