Hello everyone, I'm currently porting code from the Xmega32A to the AVR128DB48. I've managed to implement all the main routines. What I still have ahead of me is a bootloader with UART to load the update and then write it to flash. My current problem is the UART. I've been working on it for about a week now. No matter what I do, I only get "garbage" when sending. I haven't tried reading yet. I'm sending at 9600 baud. I was able to increase the clock frequency from 4 MHz internal to 16 MHz with an external crystal, and that works. It have read that the internal oscillator is not suitable for UART. I've searched a lot of forums and my code is identical to the other examples here and on the web. I'm now looking for a hex file for the AVR128 that sends a normal text string to the PC, to know if it works at all. I have tested with the AVR128 Curiosity Board and with an external RT232rs, and I sometimes get something, but only garbage. Maybe someone can help. The best would be an ASM code that sends a character. Thanks and greetings from Switzerland.
yesss.. i have found the problem in my baudrate register: Integer part: 103 → Bits [15:6] = 0x1A (26 in hex). Fractional part: 0.1666667 × 64 ≈ 11 → Bits [5:0] = 0x0B. I forgot to write the fractional part into the register. If I now write $1A0B, it works right away! If you stick with it long enough and read a lot, you’ll succeed. Greets Mike
Mike B. wrote: > the UART. I've been working on it for about a week now. > Maybe someone can help. I'm fairly sure some measurements with an oscilloscope will do the job in a few hours. Do you have one? Edit: Forgot to send my answer, but as expected Mike B. wrote: > i have found the problem in my baudrate register This problem is found within a few minutes with a scope.
:
Edited by Moderator
Hi, No, unfortunately I don't have an oscilloscope. But it would be worth getting one for problems like this. I also knew it had to have something to do with the transmission. Even if I had been able to measure it, I probably still wouldn't have understood the problem. But it's always a nice effect when it becomes clear, and your hand hits your head with a loud "oh no" Greets Mike
Mike B. wrote: > Even if I had been able to measure it, I probably still wouldn't have > understood the problem. You would have found out, that the time for one bit is not 104us as it must be for 9600 baud. And you would have been able to measure the clock frequency. The only thing between those both is the prescaler. And with all this information you would have digged in the right hole without spending time in trying this and that. Mike B. wrote: > But it would be worth getting one for problems like this. For sure. Debugging serial interfaces (pixel-leds, SPI, I2C, RS232, ...) without a scope is like driving blindly: you do not know if you are on the rigt way, you just recognize that somethings going wrong.
For issues like this, checking component specs and sourcing from trusted suppliers is key. I’ve had good experience with Jotrin at this https://www.jotrin.com/ site, when it comes to finding reliable datasheets and hard-to-find components. Their catalog helps ensure compatibility, especially when debugging timing or signal-related problems in microcontroller setups.
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.