Help getting UART output from a bitbanged port

Skip to first unread message

Kenny Luong

Oct 9, 2017, 8:29:04 PM10/9/17
to simavr
Hey folks  -

I have an Arduino-based system I'm trying to simulate and our transceiver (an XBee) is running off a bitbanged UART port. I'm trying to figure out a way to get that output through the simulator and print it out.

I'm not sure where to start, or what a good approach would be....I noticed there are some references to a bit-banging interface in the simulator, but I'm not too sure how I would use it in this context. Any advice would be greatly appreciated!



Oct 9, 2017, 9:37:14 PM10/9/17
to simavr

Currently, bit-banging is not used in simavr yet. In particular, UART module can't do bit-banging right now.
There is however my implementation for SPI which uses avr_bitbang.c module you mentioned.
It is still under development, but it works. You can use it for reference, if you want to implement UART bit-banging yourself.
See PR #249 and/or full source in my branch here.
Alternativelly, you can use simavr VCD trace facility (logic analyzer), which actually is pretty cool!
To trace activity on some MCU register, add something like that into your firmware source:
const struct avr_mmcu_vcd_trace_t _mytrace[]  _MMCU_ = {
  { AVR_MCU_VCD_SYMBOL("UDR0"), .what = (void*)&UDR0, },
  { AVR_MCU_VCD_SYMBOL("RXC0"), .mask = (1 << RXC0), .what = (void*)&UCSR0A, },}; 
Resulting trace file can be viewed using gtkwave application.
  1. To build firmware successfully put avr_mmcu_vcd_trace_t struct definition into separate source file with ".c" extension.
  2. Add the following linker option: -Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000
  3. Also, you can trace any global variables from your source code with this method. For that you have to recompile simavr with MAX_IOs set to size of the MCU SRAM instead of the default value (sim_avr.h, line 69)

Kenny Luong

Oct 10, 2017, 7:33:51 PM10/10/17
to simavr
Ah, I see. Thanks for clearing that up. I'll take a look at getting VCDs to work. Appreciate the help!
Reply all
Reply to author
0 new messages