Académique Documents
Professionnel Documents
Culture Documents
Step 2: Description
You can find a copy of the video controller software, including the source file, on his Download page. The
program was written using his SB-Assembler.
The entire program runs in one single interrupt routine. The main program is empty, well almost empty.
Interrupts are spaced exactly 64s apart for 50Hz systems, or 63.5s for 60Hz systems. Each interrupt
routine starts by generating an H-Sync pulse. A state machine then determines what is to be done during
the rest of the line. Care should be taken that the interrupt routine ends before it's time to start a new
one.
All these tasks are performed inside the interrupt routine. A simple state machine determines what task
needs to be done during each particular video line. Some lines leave no time to do anything else but
control the video/sync outputs. Other lines allow plenty of time ( >55s ) to do other tasks. These other
tasks are: accepting characters from the Apple 1, sending the characters to the serial output, scrolling the
screen, flashing the cursor, etc, etc.
When the a1video.hex-file has been loaded in the Atmega32, here a demo how to use it with the
Atmega128.
Bascom-AVR can be used to program the Atmega32. Start Bascom-AVR, push on the button program chip,
but instead of program, press on manual program. Erase the Atmega32, set the fusebits, load the buffer
with the a1video.hex file (standard there is asked for a BIN-file, you can however load a HEX-file) and
flash it into the Atmega32.
'Video demo
$regfile "m128def.dat"
$crystal = 8000000
$baud = 115200 ' first hardware UART
$baud1 = 115200 ' second hardware UART
'Hardware
'LCD
'portb.7 LCD Db7
'portb.6 LCD Db6
'portb.5 LCD Db5
'portb.4 LCD Db4
'portb.3 LCD RS
'portb.2 LCD E
'portd.4 Beeper
Dim X As Byte
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E =
Porta.2 , _
Rs = Porta.3
Config Lcd = 16 * 2
Cursor Off
Cls
Home
Lcd "Videotest"
Call Beep
Wait 3
'clear screen
Call Video_cls
Sub Beep
Set Beeper
Waitms 1
Reset Beeper
End Sub
Sub Video_pulse_rda
Set Pulse_rda
Bitwait Pine.5 , Reset
Reset Pulse_rda
End Sub
Sub Video_cls
Reset Video_clear
Waitms 5
Set Video_clear
End Sub
$regfile "m128def.dat"
$crystal = 8000000
$baud = 9600 ' first hardware UART
$baud1 = 9600 ' second hardware UART
'Hardware
'LCD
'portb.7 LCD Db7
'portb.6 LCD Db6
'portb.5 LCD Db5
'portb.4 LCD Db4
'portb.3 LCD RS
PDF created on http://www.htm2pdf.co.uk via the HTML to PDF API
'portb.2 LCD E
'portd.4 Beeper
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E =
Porta.2 , Rs = Porta.3
Config Lcd = 16 * 2
Cls
Home
Cursor Off
End
Sub Beep
Set Beeper
Waitms 2
Reset Beeper
End Sub
By removing two SMD resistors and placing two resistors on another place both buttons can be connected
to the Atmega128, so you will have a total of 5 buttons to work with.
When you put the JP4 jumpers to the right, COM2 with it's MAX3232 is connected to the VNC1L-1A and
you can type the commands from Hyperterminal at 9600 baud. When a memorystick is inserted it is
detected. First thing is looking for a file to upgrade the firmware of the VNC1L-1A.
OPW TEST.TXT
WRF 16
CLF TEST.TXT
RD TEST.TXT
'VNC - Doing a DIR of the USB-stick, create a file called AVR.TXT, add or append a line of text
and read the file back.
$regfile "m128def.dat"
$crystal = 8000000
$baud = 9600 ' first hardware UART
$baud1 = 9600 ' second hardware UART
Enable Timer1
Do
Call Reset_vnc
usb_handle = 1
Check = 10
Call Wait_for_prompt
Wait 3
Incr Teller
Loop Until Teller = 10000
End
'reset VNC1L-1A
Sub Reset_vnc
Reset Portc.7
Set Portc.7
Check = 10
Incr No_stick
If No_stick = 10 Then
Print "No stick"
Stop
End If
End Sub
Sub Wait_for_prompt
Do
Get #2 , Z
Print Chr(z);
Loop Until Z = Asc( ">")
Check = 0
No_stick = 0
End Sub
If Usb_handle = 1 Then
Decr Check
PDF created on http://www.htm2pdf.co.uk via the HTML to PDF API
If Check = 0 Then
Call Reset_vnc
End If
End If
Return
You have to format your USB memory stick with 512 bytes sector size. This can be done like this:
'PS2-keyboard
$regfile = "m128def.dat"
$crystal = 8000000
$baud = 9600
'Hardware
'LCD
'portb.7 LCD Db7
'portb.6 LCD Db6
'portb.5 LCD Db5
'portb.4 LCD Db4
'portb.3 LCD RS
'portb.2 LCD E
'portd.4 Beeper
Start VPROG_COM.EXE, select the right ROM-file, select the COM-port, press PROG on the board and
'portd.5 Clockpower-up
keyboardthe board. Shortly press RESET and the firmware update is started.
'portd.6 Data keyboard
'Portd.4 Beeper
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E =
Porta.2 , Rs = Porta.3
Config Lcd = 16 * 2
Cls
Home
Do
Input S
Do
B = Getatkbd()
Loop Until B <> 0
'Print B
Loop
End
Kbdinput1:
rCall _getatkbd ; call the function
tst r24 ; check for zero
breq Kbdinput1 ; yes so try again
pop r27 ; we got a valid key so restore registers
pop r26
pop r25
pop r16
$end Asm
'just return
Return
Keydata:
'---------------------------------------------
' Atmega128 and WIZ810MJ
'---------------------------------------------
$regfile = "m128def.dat"
$crystal = 8000000
$baud = 9600
PDF created on http://www.htm2pdf.co.uk via the HTML to PDF API
$hwstack = 128
$swstack = 128
$framesize = 128
'Hardware
'LCD
'portb.7 LCD Db7
'portb.6 LCD Db6
'portb.5 LCD Db5
'portb.4 LCD Db4
'portb.3 LCD RS
'portb.2 LCD E
'portd.4 Beeper
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E =
Porta.2 , Rs = Porta.3
Config Lcd = 16 * 2
PDF created on http://www.htm2pdf.co.uk via the HTML to PDF API
$include "w5100.inc"
Wait 1
Cls
Home
Cursor Off
Lcd "Seaportlighting"
Lowerline
Call Beep
Lcd "Wiz810MJ-test "
PDF created on http://www.htm2pdf.co.uk via the HTML to PDF API
Wait 1
Do
Loop
End
Sub Wiz5100_init
Call Wiz5100_reset 'Hardware reset
'Register reset
Call Wiz5100_writevalue(w5100_mr , &H80)
'Set gateway IP adress
Call Wiz5100_writevalue(w5100_gar0 , 192) 'My gateway
Call Wiz5100_writevalue(w5100_gar1 , 168)
Call Wiz5100_writevalue(w5100_gar2 , 0)
Call Wiz5100_writevalue(w5100_gar3 , 254)
'Set Subnetmask
Call Wiz5100_writevalue(w5100_subr0 , 255) 'My networkmask
Call Wiz5100_writevalue(w5100_subr1 , 255)
Call Wiz5100_writevalue(w5100_subr2 , 255)
Call Wiz5100_writevalue(w5100_subr3 , 0)
'Set MAC
Call Wiz5100_writevalue(w5100_shar0 , 0) 'My MAC-address
Call Wiz5100_writevalue(w5100_shar1 , 1)
Call Wiz5100_writevalue(w5100_shar2 , 2)
Call Wiz5100_writevalue(w5100_shar3 , 3)
Call Wiz5100_writevalue(w5100_shar4 , 4)
Call Wiz5100_writevalue(w5100_shar5 , 5)
'Set own IP adress
Call Wiz5100_writevalue(w5100_sipr0 , 192) 'My IP-number
Call Wiz5100_writevalue(w5100_sipr1 , 168)
Call Wiz5100_writevalue(w5100_sipr2 , 0)
Call Wiz5100_writevalue(w5100_sipr3 , 50)
End Sub
Sub Wiz5100_readvalue(reg)
Adres = Reg
Reset Wiz5100_cs
Spiout Wiz5100_opcode_read , 1
Spiout Adresh , 1
Spiout Adresl , 1
Spiin Value , 1
PDF created on http://www.htm2pdf.co.uk via the HTML to PDF API
Set Wiz5100_cs
End Sub
Sub Wiz5100_reset
Waitms 250
Wiz5100_res = 1
Waitms 250
Wiz5100_res = 0
Waitms 250
Wiz5100_res = 1
End Sub
Sub Beep
Set Beeper
Waitms 2
Reset Beeper
End Sub
To check if the DS1307Z+ can be found on the I2c-bus I use the I2c-scanner which I wrote a few years
More examples for the WIZ810MJ can be found here:
back.
http://members.home.nl/bzijlstra/software/examples/wiz810mj.htm
$regfile "m128def.dat"
$crystal = 8000000
Baud = 9600
Dim Yn As String * 1
Dim Adrx As Word
Dim Row As Byte
PDF created on http://www.htm2pdf.co.uk via the HTML to PDF API
$lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI
Config Scl = Portd.0 ' we need to provide the SCL pin name
Config Sda = Portd.1 ' we need to provide the SDA pin name
End
Thanks to: