1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#! @TCL_WISH@
#
###############################################################################
#
# LCD and Serial IO example for simulavrxx
#
# Last modifications:
# 02-Sep-2008 KSchwi previous example LCD extended by Serial Rx / TX
#
###############################################################################
#
# $Id$
#
#
#set traceFile trace
#we use some itcl :-)
package require Itcl
#load the avr-simulator package
load @top_builddir@/src/.libs/libsimulavr.so
puts "simulavr loaded"
#now start external generic gui server
exec @TCL_WISH@ ../gui.tcl &
#start the trace output to given filename
#StartTrace $traceFile
#start the user interface client
set ui [new_UserInterface 7777 ]
#create new device
set dev1 [new_AvrDevice_atmega128]
#load elf file to the device
AvrDevice_Load $dev1 "./stdiodemo.elf"
#set the clock cycle time [ns]. Here ~3.686400 MHz
AvrDevice_SetClockFreq $dev1 271
#systemclock must know that this device will be stepped from application
set sc [GetSystemClock]
#also the gui updates after each cycle
$sc AddAsyncMember $ui
# Serial transmitter and receiver Net
Net ser_rxD0
Net ser_txD0
#create a Pin for serial in and serial out of the LCD-board
ExtPin exttxD0 $Pin_PULLUP $ui "txD0" ".x"
ExtPin extrxD0 $Pin_PULLUP $ui "rxD0" ".x"
#create a serial in and serial out component
SerialRx mysrx $ui "serialRx0" ".x"
SerialRxBasic_SetBaudRate mysrx 9600
SerialTx mystx $ui "serialTx0" ".x"
SerialTxBuffered_SetBaudRate mystx 9600
# wire the serial display receiver
ser_rxD0 Add [AvrDevice_GetPin $dev1 "E1"]
ser_rxD0 Add extrxD0
ser_rxD0 Add [SerialRxBasic_GetPin mysrx "rx"]
# wire the serial display transmitter
ser_txD0 Add [AvrDevice_GetPin $dev1 "E0"]
ser_txD0 Add exttxD0
ser_txD0 Add [SerialTxBuffered_GetPin mystx "tx"]
#create an LCD name mylcd
Lcd mylcd $ui "lcd0" ".x"
$sc AddAsyncMember mylcd
#Create for the Pins d0 - d4, e, r, c a Net and
#connect the LCD pins to the AVR pins
# "r" = Read / Write
# "c" = command / Data
# "e" = Enable
Net E
E Add [Lcd_GetPin mylcd "e"]
E Add [AvrDevice_GetPin $dev1 "C7"]
Net RW
RW Add [Lcd_GetPin mylcd "r"]
RW Add [AvrDevice_GetPin $dev1 "C6"]
Net CD
CD Add [Lcd_GetPin mylcd "c"]
CD Add [AvrDevice_GetPin $dev1 "C5"]
Net D3
D3 Add [Lcd_GetPin mylcd "d3"]
D3 Add [AvrDevice_GetPin $dev1 "C3"]
Net D2
D2 Add [Lcd_GetPin mylcd "d2"]
D2 Add [AvrDevice_GetPin $dev1 "C2"]
Net D1
D1 Add [Lcd_GetPin mylcd "d1"]
D1 Add [AvrDevice_GetPin $dev1 "C1"]
Net D0
D0 Add [Lcd_GetPin mylcd "d0"]
D0 Add [AvrDevice_GetPin $dev1 "C0"]
#exec xterm -e tail -f $traceFile &
puts "Simulation runs endless, please press CTRL-C to abort"
GdbServer gdb1 $dev1 1212 0
$sc Add gdb1
exec @DDD_WITH_ARGS@ avr-gdb --command @srcdir@/checkdebug.gdb &
#now run simulation
$sc Endless
|