![](https://benshobbycorner.nl/hobbycorner/images/bens.gif)
![](https://benshobbycorner.nl/hobbycorner/images/bttr.gif) |
Here you can find
a step-by-step tutorial about the Bascom-AVR code
to drive an AVR
and an WIZ830MJ Ethernet controller.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/WIZ830MJ.jpg)
This tutorial is based on the Arduino Mega shield with WIZ830MJ, VS1053
MP3 decoder,
Micro-SD-slot, 128 Kbyte SRAM from Michael Köcher
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/topview.jpg)
This is the Arduino Mega Shield. Left the
VS1053 MP3 decoder, right the WIZ830MJ-ethernetmodule
WebShop Köcher Elektronik
Step 1. The hardware...
|
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/IMAG0008_k.jpg)
Details of the
Micro-SD-slot and 128 Kbyte SRAM.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/ard_mega_zonder.jpg)
This is the Arduino Mega
I am using. From DFRobot. But you can also find one in the shop of
Köcher.
Take a piece of plastic and shape it like the top of the USB-connector.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/ard_mega_met.jpg)
Glue it on top of the
connector to prevent shortage with the shield.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/sideview2.jpg)
Side view
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/sideview1.jpg)
Side view
We don't have to do
anything with the fusebits of the Arduino Mega.
It has a bootloader and the fusebits look like this:
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/fusebits.jpg)
This is the way I got
hold of the fusebits, putting an AVRISP cable on the ISP connector of
the Arduino Mega. I used a 6-to-10 converter from Sparkfun.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/avrisp.jpg)
|
Step
2: First check, a memorytest |
This will be our first program.
First, start with a small description what you are planning to do
with date and/or version-number.
'----------------------------------------------------------------------------------------
' Arduino Mega - with Köcher shield - WIZ830, Micro-SD, 128 Kbyte
SRAM, VS1053 MP3
'---------------------------------------------------------------------------------------
' Version 1.0 - April 2011
$crystal = 16000000
$regfile = "m1280def.dat"
$hwstack = 64
$swstack = 64
$framesize = 64
$crystal is used to
give the MHz or Megacycles you are using.
$regfile is used to have Bascom-AVR use the right registers for the
right microcontroller. In this case we are using a Atmega1280.
This is a picture of the memorymap of
the Atmega1280. On this board we have a single 128 Kbyte SRAM which can
be split in a lower and a upper bank of 64 Kbyte.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/memmap.jpg)
'-------------------------------------------------------------------------------
' 64/128KB XRAM
'-------------------------------------------------------------------------------
' $0000 - $01FF = AVR Regs
' $0200 - $21FF = int 4KB Sram
' $2200 - $FC00 = external Sram (lower)
' $2200 - $FC00 = external Sram (upper)
' $FC00 - $FFFF = WIZ830MJ
'
$xramstart = &H2200
$xramsize = &HFBFF
Config Xram = Enabled
Open "Com1:" For Binary As #1
Print #1 , "Memorytest"
Dim B As Word
Dim C As Byte
Ucsr1b.txen1 = 0 'disable
USARTB
Ucsr1b.rxen1 = 0
Ucsr2b.txen1 = 0 'disable USARTB
Ucsr2b.rxen1 = 0
Upper_bank Alias Porth.0
Config Upper_bank = Output
Reset Upper_bank
For B = &H2200 To &HFBFF
Out B , &HAA
Next
Set Upper_bank
For B = &H2200 To &HFBFF
Out B , &H55
Next
Reset Upper_bank
For B = &H2200 To &HFBFF
C = Inp(b )
Print #1 , Hex(b) ; ": $"
; Hex(c)
Next
Set Upper_bank
For B = &H2200 To &HFBFF
C = Inp(b )
Print #1 , Hex(b) ; ": $"
; Hex(c)
Next
Reset Upper_bank
End
Compile this and put this in the Arduino Mega
with the USB-cable and the next Bascom-AVR programmer settings:
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/program_settings.jpg)
Have put
AVRDUDE.EXE and
AVRDUDE.CONF in the C :\programmer directory.
The complete parameter is:
-v -F -Cc:\programmer\avrdude.conf -p m1280
-P com4 -c STK500v1 -b 57600 -Uflash:w:{FILE}:a
Or, and that is new in Bascom-AVR 2.0.5.0 with
the selection ARDUINO as programmer.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/prog_arduino.jpg)
If everything is correct, and you have opened
the Bascom-AVR terminal or another terminal program with 57600 baud you
will see something like this:
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/hyp1.jpg)
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
ard_wiz_memorytest.bas
ard_wiz_memorytest.hex
BTW: A good choice Michael Köcher did
with the Arduino Mega as base-board for his shield.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/mega.jpg)
|
Step
3:
Ping-test |
1578
bytes!!
1578 bytes, that
is all you need to get PING working on the WIZ830MJ-module.
Can shorter but Six1 made use of some special features.
'-----------------------------------------------------------------
' Atmega1280 and WIZ830MJ All you need to get a PING working
'-----------------------------------------------------------------
' Arduino Mega WIZ830MJ - MP3 -
Micro-SD - 128 Kbyte SRam
'
' PING test
$regfile = "m1280def.dat"
$crystal = 16000000
$baud = 57600
$hwstack = 128
$swstack = 128
$framesize = 128
'-------------------------------------------------------------------------------
' 64/128KB XRAM
'-------------------------------------------------------------------------------
' $0000 - $01FF = AVR Regs
' $0200 - $21FF = int 4KB Sram
' $2200 - $FC00 = external Sram (lower)
' $2200 - $FC00 = external Sram (upper)
' $FC00 - $FFFF = WIZ830MJ
'
$xramstart = &H2200
$xramsize = &HFBFF
Config Xram = Enabled
Open "Com1:" For Binary As #1
Print #1 , "Pingtest"
Declare Sub Wiz_init()
Declare Sub Wiz_write(byval Address_a As Word , Byval Data_a As Byte)
Declare Sub Wiz_set_network(byval Typ As Byte , Byref Address As Byte)
Dim W5300_ip(4) As Byte
Dim W5300_mac(6) As Byte
Dim W5300_mask(4) As Byte
Dim W5300_gw(4) As Byte
Ucsr1b.txen1 = 0 'disable USARTB
Ucsr1b.rxen1 = 0
Ucsr2b.txen1 = 0 'disable USARTB
Ucsr2b.rxen1 = 0
$include "w5300.inc"
W5300_ip(1) = 192
W5300_ip(2) = 168
W5300_ip(3) = 0
W5300_ip(4) = 71
W5300_mac(1) = &H11
W5300_mac(2) = &H22
W5300_mac(3) = &H33
W5300_mac(4) = &H44
W5300_mac(5) = &H55
W5300_mac(6) = &H66
W5300_mask(1) = 255
W5300_mask(2) = 255
W5300_mask(3) = 255
W5300_mask(4) = 0
W5300_gw(1) = 192
W5300_gw(2) = 168
W5300_gw(3) = 0
W5300_gw(4) = 1
Call Wiz_init
End
'-------------------------------------------------------------------------------
' Set W5300 common Registers and
reset device
'-------------------------------------------------------------------------------
Sub Wiz_init()
Local X As Byte , Y As Byte
'Reset Device
Call Wiz_write(w5300_mr1 , Mr_rst)
'wait PLL lock
Waitms 5
'indirect addressing
Call Wiz_write(w5300_mr1 , Mr_ind)
Waitms 10
'Set memory
'1st to 8th Memory Block as RX memory
Call Wiz_write(w5300_mtyper0 , 0)
'9th to 16th Memory Block as TX memory
Call Wiz_write(w5300_mtyper1 , &HFF)
Call Wiz_write(w5300_tmsr0 , 8)
Call Wiz_write(w5300_tmsr1 , 8)
Call Wiz_write(w5300_tmsr2 , 8)
Call Wiz_write(w5300_tmsr3 , 8)
Call Wiz_write(w5300_tmsr4 , 8)
Call Wiz_write(w5300_tmsr5 , 8)
Call Wiz_write(w5300_tmsr6 , 8)
Call Wiz_write(w5300_tmsr7 , 8)
Call Wiz_write(w5300_rmsr0 , 8)
Call Wiz_write(w5300_rmsr1 , 8)
Call Wiz_write(w5300_rmsr2 , 8)
Call Wiz_write(w5300_rmsr3 , 8)
Call Wiz_write(w5300_rmsr4 , 8)
Call Wiz_write(w5300_rmsr5 , 8)
Call Wiz_write(w5300_rmsr6 , 8)
Call Wiz_write(w5300_rmsr7 , 8)
Waitms 5
'Set gateway adress
Call Wiz_set_network(1 , W5300_gw(1))
'Set Mask
Call Wiz_set_network(2 , W5300_mask(1))
'Set Ip adress
Call Wiz_set_network(3 , W5300_ip(1))
'Set Mac adress
Call Wiz_set_network(4 , W5300_mac(1))
'set Interrupt Mask
Call Wiz_write(w5300_imr0 , &H0F)
'for getting Sock Int should be $FF for 8 Socks
'Allow Interrupts on Sockets
Call Wiz_write(w5300_imr1 , $ff)
End Sub
'-------------------------------------------------------------------------------
' Write Wiznet Base Register Adress Data
'-------------------------------------------------------------------------------
Sub Wiz_write(byval Address_a As Word , Byval Data_a As Byte)
Out Address_a , Data_a
End Sub
-------------------------------------------------------------------------------
' Set Network Parameters
'-------------------------------------------------------------------------------
Sub Wiz_set_network(byval Typ As Byte , Byref Address As Byte)
Local Dest_address As Word , Laddr As Word , Lb As Byte , Count As Byte
, X As Byte
Select Case Typ
'Gateway
Case 1 : Dest_address = W5300_gar0
Count = 4
'Mask
Case 2 : Dest_address = W5300_subr0
Count = 4
'Ip
Case 3 : Dest_address = W5300_sipr0
Count = 4
'Mac
Case 4 : Dest_address = W5300_shar0
Count = 6
Case Else Exit Sub
End Select
Laddr = Varptr(address) : Lb = Inp(laddr)
For X = 1 To Count
Call Wiz_write(dest_address , Lb)
Incr Dest_address
Incr Laddr
Lb = Inp(laddr)
Next
End Sub
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/ping.jpg)
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
ard_wiz_pingtest.bas
ard_wiz_pingtest.hex |
Include file - W5300.INC.... |
Here all registers in an Include file.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
$include "W5300.inc"
|
Step 4:
VS1053-test |
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/vs1053.jpg)
This is de VS1053-MP3 decoder module used on the
board.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/vs1053_connector.jpg)
This is the way the VS1053 MP3 module is connected
to the board.
' Arduino Mega WIZ830MJ - MP3 -
Micro-SD - 128 Kbyte SRam
'
' MP3-decoder test
$regfile = "m1280def.dat"
$crystal = 16000000
$hwstack = 250
$swstack = 250
$framesize = 250
$baud = 57600
Const Clear_cs = 0
Const Set_cs = 1
Vs1053_dreq Alias Pinl.2
Config Vs1053_dreq = Input
Vs1053_dreq = 1
Vs1053_xcs Alias Portl.0
Config Vs1053_xcs = Output
Vs1053_xcs = Set_cs
Vs1053_xdcs Alias Portl.3
Config Vs1053_xdcs = Output
Vs1053_xdcs = Set_cs
Vs1053_xres Alias Portl.1
Config Vs1053_xres = Output
Set Vs1053_xres
Vs1053_xdcs = Clear_cs
Vs1053_xcs = Clear_cs
'Opcodes
Const Vs_read = $03
Const Vs_write = $02
'Registers
Const Vs_mode = $00 ' Mode Control
Const Sm_reset = $04 'Soft Reset
Const Sm_cancel = $08 'Cancel Decoding
Const Sm_tests = $20 ' Test mode
Const Sm_stream = $40 'Stream Mode
Const Sm_sdinew = &B00001000_00000000 'VS1002 native SPI modes
Const Sm Sdishared = &B00000100_00000000
Const Vs_status = $01 'Status
Const Vs_bass = $02 'Built-in bass/treble enhancer
Const Vs_clockf = $03 'Clock freq + multiplier
Const Sc_mul_2x = $2000
Const Sc_mul_4x = $a000
Const Vs_decode_time = $04 'Decode time in seconds
Const Vs_audata = $05 'Misc. audio data
Const Vs_wram = $06 'RAM write/read
Const Vs_wramaddr = $07 'Base address for RAM write/read
Const Vs_hdat0 = $08 'Stream header data 0
Const Vs_hdat1 = $09 'Stream header data 1
Const Vs_aiaddr = $0a 'Start address of application
Const Vs_vol = $0b 'Volume control
Const Vs_aictrl0 = $0c 'Application control register 0
Const Vs_aictrl1 = $0d 'Application control register 1
Const Vs_aictrl2 = $0e 'Application control register 2
Const Vs_aictrl3 = $0f 'Application control register 3
Const Vs_reset_enable = 0
Const Vs_reset_disable = 1
' Define here SS Pin of HW-SPI of the CPU (f.e. Pinb.0 on M1280)
Config Pinb.0 = Output ' define here Pin of SPI SS
Spi_ss Alias Portb.0
Set Spi_ss ' Set SPI-SS to Output and High por Proper work of
' SPI as Master
' HW-SPI is configured to highest Speed
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes ,
Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 1
Spiinit ' Init SPI
Declare Sub Init()
Declare Sub Vs_write_command(byval Address As Byte , Byval Write_data As
Word)
Declare Sub Vs_write_data(byval Write_data As Byte)
Declare Sub Vs_set_volume(byval Volume As Byte)
Declare Sub Vs_check_dreq()
Declare Sub Vs_play_mp3
Dim Mp3_data(600) As Byte
Print "MP3 Test"
Call Init()
Call Vs_play_mp3
Print "Done sending MP3."
End
Sub Vs_play_mp3
Local I As Word , J As Byte , Curbyte As Word
Local Z As Word , Teller As Word
Call Vs_check_dreq
Restore Mp3
Teller = 40960
Do
For Z = 1 To 512
Read Mp3_data(z)
Decr Teller
Next Z
Curbyte = 1
For I = 1 To 16
Call Vs_check_dreq
Vs1053_xdcs = Clear_cs
Spiout Mp3_data(curbyte) , 32
Vs1053_xdcs = Set_cs
Curbyte = Curbyte + 32
Next I
Curbyte = 1
Loop Until Teller = 0
'fill up with 2048 Byte to be shure all the File will be played
' so there is no music left at buffer...
For I = 1 To 2048
J = 0
Call Vs_write_data(j)
Next I
End Sub
Sub Vs_check_dreq()
Do
Loop Until Vs1053_dreq = 1
End Sub
Sub Init()
' Soft Reset
Call Vs_write_command(vs_mode , $0004 )
Waitms 2
Call Vs_write_command(vs_mode , &B00001000_00000000 )
Waitms 2
'Set Clock
Call Vs_write_command(vs_clockf , $1800 + Sc_mul_2x)
Waitms 2
Call Vs_set_volume(10)
End Sub
Sub Vs_write_command(byval Address As Byte , Byval Write_data As Word)
Local B_b As Byte
Vs1053_xcs = Clear_cs
B_b = Vs_write
Spiout B_b , 1
Spiout Address , 1
B_b = High(write_data)
Spiout B_b , 1
B_b = Low(write_data)
Spiout B_b , 1
Vs1053_xcs = Set_cs
End Sub
Sub Vs_write_data(byval Write_data As Byte)
Vs1053_xdcs = Clear_cs
Spiout Write_data , 1
Vs1053_xdcs = Set_cs
End Sub
Sub Vs_set_volume(byval Volume As Byte)
Local Vol_word As Word
If Volume = 0 Then
Call Vs_write_command(vs_vol , $ffff)
Else
Volume = 100 - Volume
Shift Vol_word , Left , 8
Vol_word = Vol_word + Volume
Call Vs_write_command(vs_vol , Vol_word)
End If
End Sub
$inc Mp3 , Nosize , "listen1.mp3"
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
ard_wiz_mp3test.bas
ard_wiz_mp3test.hex
And this is the original MP3-file:
Listen1.mp3 |
Step 5: Micro-SD Card -
playing MP3 and MIDI-files |
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/micro_sd.jpg)
Micro-SD-card slot
' Arduino Mega WIZ830MJ - MIDI - Micro-SD - 128 Kbyte SRam
'
' MIDI TEST six1/04-2011
$regfile = "m1280def.dat"
$crystal = 16000000
$hwstack = 250
$swstack = 250
$framesize = 250
$baud = 57600
Const Clear_cs = 0
Const Set_cs = 1
'-------------------------------------------------------------------------------
' Setup VS1053 Modul
'-------------------------------------------------------------------------------
Vs1053_dreq Alias Pinl.2
Config Vs1053_dreq = Input
Vs1053_dreq = 1
Vs1053_xcs Alias Portl.0
Config Vs1053_xcs = Output
Vs1053_xcs = Set_cs
Vs1053_xdcs Alias Portl.3
Config Vs1053_xdcs = Output
Vs1053_xdcs = Set_cs
Vs1053_xres Alias Portl.1
Config Vs1053_xres = Output
Set Vs1053_xres
Vs1053_xdcs = Clear_cs
Vs1053_xcs = Clear_cs
$include "VS1053.inc"
'-------------------------------------------------------------------------------
' SD CARD
'-------------------------------------------------------------------------------
$include "Config_mmc.bas"
Declare Sub Sdcard_initialize
Declare Sub Sdcard_init_filesystem
Declare Sub Vs_init()
Declare Sub Vs_soft_reset()
Declare Sub Vs_write_command(byval Address As Byte , Byval Write_data As
Word)
Declare Sub Vs_write_data(byval Write_data As Byte)
Declare Sub Vs_set_volume(byval Volume As Byte)
Declare Sub Vs_set_bass_treble(byval Treble As Byte , Byval Bass As
Byte)
Declare Sub Vs_check_dreq()
Declare Sub Vs_play_file(byval Filename As String)
Declare Sub Activate_vs1053
Declare Sub Activate_sdcard
Dim Tone_w As Word
Dim Tone_treble As Byte At Tone_w + 1 Overlay
Dim Tone_bass As Byte At Tone_w Overlay
Dim Mmc_data(32) As Byte
Dim Next_filename As String * 30
Dim File_len As Long
Print "MIDI Test"
Call Sdcard_initialize
Call Vs_init()
'load first midi file with mask
Call Activate_sdcard
Next_filename = Dir( "*.MID")
Do
Call Vs_soft_reset
Call Vs_play_file(next_filename)
Call Activate_sdcard
Next_filename = Dir()
Loop Until Next_filename = ""
Print "Done playing all MIDI :-)"
'load mp3 file with mask
Call Activate_sdcard
Next_filename = Dir( "*.MP3")
Do
Call Vs_soft_reset
Call Vs_play_file(next_filename)
Call Activate_sdcard
Next_filename = Dir()
Loop Until Next_filename = ""
Print "Done playing all MP3 :-)"
End
Sub Vs_play_file(byval Filename As String)
Local I As Word , J As Byte , Curbyte As Word
'Open the file.
Call Activate_sdcard
File_len = Filelen(filename)
Print "now Playing " ; Filename ; " " ; File_len ; " Byte"
Open Filename For Binary As #10
Curbyte = 1
While Eof(#10) = 0
Call Activate_sdcard
Get #10 , Mmc_data(1) , , 32
Call Activate_vs1053()
Call Vs_check_dreq
Spiout Mmc_data(1) , 32
Curbyte = Curbyte + 32
Wend
Close #10
'fill up with 2048 Byte to be shure all the File will be played
' so there is no music left at buffer...
For I = 1 To 2048
J = 0
Vs1053_xdcs = Clear_cs
Spiout J , 1
Vs1053_xdcs = Set_cs
Next I
End Sub
Sub Activate_sdcard
Set Vs1053_xdcs
Reset Spi_ss
End Sub
Sub Activate_vs1053
Set Spi_ss
Reset Vs1053_xdcs
End Sub
Sub Vs_check_dreq()
Do
Loop Until Vs1053_dreq = 1
End Sub
'-------------------------------------------------------------------------------
' Soft Reset of VS10xx (Between songs) with Patch
'-------------------------------------------------------------------------------
Sub Vs_soft_reset()
Local Help_w As Word
Call Vs_write_command(vs_mode , Sm_sdinew_reset)
Waitms 1
Call Vs_check_dreq()
Call Vs_write_command(spi_clockf , Sc_mul_4x)
Call Vs_check_dreq()
End Sub
'-------------------------------------------------------------------------------
' Hard Reset of VS10xx with Patch
'-------------------------------------------------------------------------------
Sub Vs_init()
Local Help_w As Word , B_b As Byte
' hard reset
Set Vs1053_xres
Reset Vs1053_xres
Waitms 1
B_b = &HFF
Spiout B_b , 1
Set Vs1053_xres
Call Vs_check_dreq()
'Set clock register, doubler etc.
Call Vs_write_command(spi_clockf , Sc_mul_3x)
Waitms 1
Call Vs_check_dreq()
Help_w = &HC013
Call Vs_write_command(vs_wramaddr , Help_w)
Call Vs_soft_reset
Help_w = &HC013
Call Vs_write_command(vs_wramaddr , Help_w)
Call Vs_set_volume(80)
Call Vs_write_command(spi_clockf , Sc_mul_2x)
End Sub
Sub Vs_write_command(byval Address As Byte , Byval Write_data As Word)
Local B_b As Byte
Vs1053_xcs = Clear_cs
B_b = Vs_write
Spiout B_b , 1
Spiout Address , 1
B_b = High(write_data)
Spiout B_b , 1
B_b = Low(write_data)
Spiout B_b , 1
Vs1053_xcs = Set_cs
End Sub
Sub Vs_write_data(byval Write_data As Byte)
Set Mmc_cs
Vs1053_xdcs = Clear_cs
Spiout Write_data , 1
Vs1053_xdcs = Set_cs
Reset Mmc_cs
End Sub
'-------------------------------------------------------------------------------
' Vs_set_volume 0..100
'-------------------------------------------------------------------------------
Sub Vs_set_volume(byval Volume As Byte)
Local Vol_word As Word
If Volume = 0 Then
Call Vs_write_command(vs_vol , $ffff)
Else
Volume = 100 - Volume
Vol_word = Volume
Shift Vol_word , Left , 8
Vol_word = Vol_word Or Volume
Call Vs_write_command(vs_vol , Vol_word)
End If
' Waitms 2
End Sub
'-------------------------------------------------------------------------------
' Bass 0..15
' Treble 0..15
'-------------------------------------------------------------------------------
Sub Vs_set_bass_treble(byval Treble As Byte , Byval Bass As Byte)
' Bit 15-12 Treble : -8 to 7 0=OFF
' Bit 11- 8 upper Frequency limit in 1000Hz Steps (1..15)
' Bit 7- 4 Bass 0-15 0=OFF
' Bit 3- 0 lower Frequency limit in 10Hz Steps (2..15)
'treble from -8 to 7 !!!
If Treble > 0 And Treble < 9 Then
Treble = Treble + 8
Elseif Treble > 0 Then
Treble = Treble - 8
End If
Tone_treble = Treble
Shift Tone_treble , Left , 4
Tone_treble = Tone_treble Or 10
Tone_bass = Tone_bass Or Bass
Shift Tone_bass , Left , 4
Tone_bass = Tone_bass Or 10
Call Vs_write_command(vs_bass , Tone_w)
' Waitms 2
End Sub
Sub Sdcard_initialize
Call Sdcard_init_filesystem
If Btemp1 <> 0 Or Gbdriveerror <> 0 Then
Print "!!! RESTART FILESYSTEM !!!"
Wait 1
Goto 0
End If
End Sub
Sub Sdcard_init_filesystem
Reset Mmc_cs
Print "-> Bind SD-Card -> ";
If Gbdriveerror = 0 Then
Print "Status OK"
$include "CONFIG_AVR-DOS.bas"
Btemp1 = Initfilesystem(1)
Print "-> Bind DOS Filesystem -> ";
If Btemp1 = 0 Then
Print "Status OK"
Else
Print "failed (" ; Btemp1
; ")"
End If
Else
Print "failed"
End If
End Sub
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
m1280_mp3_midi.bas
m1280_mp3_midi.hex
config_avr-dos.bas
config_mmc.bas
vs1053.inc
igotafeeling.mid
|
Arduino Mega
pin-configuration |
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/links_pin_mega.jpg)
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/rechts_pin_mega.jpg)
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/onder_pin_mega.jpg)
Source: Forum www.arduino.cc
|
Arduino-code |
Sparkfun came out with a new
Arduino VS1053 shield. Adding two lines and their code is running on
this board!!
Change these lines:
#define MP3_XCS 49 //Control
Chip Select Pin (for accessing SPI Control/Status registers) was 9
#define MP3_XDCS 46 //Data Chip Select / BSYNC Pin was 2
#define MP3_DREQ 47 //Data Request Pin: Player asks for more data was 3
#define MP3_RST 48 //Reset VS1053
void setup() {
pinMode(MP3_DREQ, INPUT);
pinMode(MP3_XCS, OUTPUT);
pinMode(MP3_XDCS, OUTPUT);
pinMode(MP3_RST, OUTPUT);
<-- add this line in the void setup()
//Initialize VS1053 chip
digitalWrite(MP3_RST, HIGH);
<-- add this line in the void setup()
digitalWrite(MP3_XCS, HIGH); //Deselect control
digitalWrite(MP3_XDCS, HIGH); //Deselect data
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
MP3_Shield_Example_six1.pde
Thanks Nathan Seidle from SparkFun Electronics
www.sparkfun.com
|
|
|
WIZ830 - Ethernetmodule |
Address selection:
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/selectie.jpg)
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/wiz_adres.jpg)
Address of the WIZ830:
&HFC00 - &HFF00
This address you can
find back as Reg-Base in the
W5300.inc-file
$nocompile
'
'Includefile for W5300
Const Socket_reg_base = &H200
Const Socket_reg_size = &H40
Const Reg_base
= &HFC00
'Mode register
Const W5300_mr = Reg_base
Const W5300_mr0 = W5300_mr
Const W5300_mr1 = W5300_mr + 1
'interrupt
Const W5300_ir = Reg_base
+ &H2
Const W5300_ir0 = W5300_ir
Const W5300_ir1 = W5300_ir + 1
Const W5300_imr = Reg_base
+ &H4
Const W5300_imr0 = W5300_imr
Const W5300_imr1 = W5300_imr + 1
'Source Hardware Address registers
Const W5300_shar0 = Reg_base
+ &H8
Const W5300_shar1 = W5300_shar0 + 1
Const W5300_shar2 = W5300_shar0 + 2
Const W5300_shar3 = W5300_shar0 + 3
Const W5300_shar4 = W5300_shar0 + 4
Const W5300_shar5 = W5300_shar0 + 5
'Gateway address registers
Const W5300_gar0 = Reg_base
+ &H10
Const W5300_gar1 = W5300_gar0 + 1
Const W5300_gar2 = W5300_gar0 + 2
Const W5300_gar3 = W5300_gar0 + 3
'Subnet mask Address registers
Const W5300_subr0 = Reg_base
+ &H14
Const W5300_subr1 = W5300_subr0 + 1
Const W5300_subr2 = W5300_subr0 + 2
Const W5300_subr3 = W5300_subr0 + 3
'Source IP Address registers
Const W5300_sipr0 = Reg_base
+ &H18
Const W5300_sipr1 = W5300_sipr0 + 1
Const W5300_sipr2 = W5300_sipr0 + 2
Const W5300_sipr3 = W5300_sipr0 + 3
'Transmit memory size of each SOCKET reigster
Const W5300_tms01r = Reg_base
+ &H20
Const W5300_tms23r = W5300_tms01r + 2
Const W5300_tms45r = W5300_tms01r + 4
Const W5300_tms67r = W5300_tms01r + 6
|
|
|
WIZ830.exe |
To configure the Arduino
Mega WIZ830 board you need the program WIZ830.exe.
In the software a socket is reserved to do remote configuration over the
netwerk.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
Click on the picture to get the program
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/dhcp4.jpg)
|
Serveral debug options |
Here Debug_DHCP at work
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/dhcp1_term.jpg)
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/dhcp2_term.jpg)
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/dhcp3_term.jpg)
We got 192.168.0.228 and
we got the time from a NTP-server
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/dhcp3.jpg)
And here the entry in
the DHCP IP Table of my router. wiz830 on 192.168.0.228 with MAC-address
00:22:33:44:55:66 and a leasetime of 12 hours.
|
Time to get some source
code published... |
These files are in my project directory.
The main program is called wiz830_v2-3_workversion.bas
and it has a lot of routines.inc and declaration.inc include files.
And later on, with SMTP, MySQL etc. you
will see more include-files.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
wiz830_v2-3_workversion.bas
w5300.inc
w5300_routines.inc
w5300_declarations.inc
wiz830_udp_declarations.inc
wiz830_udp_routines.inc
wiz830_tcp_declarations.inc
wiz830_tcp_routines.inc
wiz830_softclock_declarations.inc
wiz830_softclock_routines.inc
wiz830_ntp_declarations.inc
wiz830_ntp_routines.inc
wiz830_http_declaractions.inc
wiz830_http_routines.inc
wiz830_dhcp_declarations.inc
wiz830_dhcp_routines.inc
w5300_eeram_declarations.inc
w5300_eeram_routines.inc
AVR-DOS_declaration.inc
wiz830_v2-3_workversion.hex |
|
|
|
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/under_construction.jpg)
Under construction
|
|
|
UDP-Command |
The software from SIX1 has been
made very modulair and it is very easy to add or delete some
include-files and have the Wiz830 do something completely different. An
example from Pf@nne -
www.bascom-forum.de, a
UDP-Command routine. It is adapted from the WIZ200WEB-software to the
WIZ830-software. Some minor changes...
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/udp_command.jpg)
Checkout
WIZ200-Commandbyte: 200, 201 and 11.
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/udp_terminal.jpg)
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/download.gif)
w5300.inc
w5300_declarations.inc
w5300_routines.inc
wiz830_softclock_declarations.inc
wiz830_softclock_routines.inc
wiz830_udp_command_declarations.inc
wiz830_udp_command_routines.inc
wiz830_udp_declarations.inc
wiz830_udp_routines.inc
wiz830_udp_command_routines_v1.1.bas
wiz830_udp_routines_v1.1.hex
UDP_Command V1.11.exe
Thanks Pf@nne!!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example of a webpage |
![](https://benshobbycorner.nl/hobbycorner/images/wiz830/webpage.jpg)
|
Thanks
to: |
![](https://benshobbycorner.nl/hobbycorner/images/xnederland.gif)
Thanks
to Mark Alberts
the creator of Bascom-AVR
www.mcselec.com
Bought my copy of Bascom-8051 in 1995
a few years later Bascom-AVR
Great stuff!!!
![](https://benshobbycorner.nl/hobbycorner/images/xduits.gif)
Thanks
to Michael Köcher
He created the Arduino Shield with WIZ830, 128 Kbyte SRAM, VS1053 MP3
decoder,
Micro-SD-slot and wrote the Bascom-AVR-code for it.
Flags can be downloaded at
www.3DFlags.com
|
Ben
Zijlstra - Ben's HobbyCorner - 2011 |
|