Skip to content

WizNet W7100 on the iMCU7100 evaluation board

webserver display

louis_m

Published January 31, 2023

Original author: ben's HobbyOriginal source (new tab)

WizNet W7100 on the iMCU7100 evaluation board

Components

Hardware components

Project description

Step 1. To-Do...

 

There is a new Circuit Cellar Contest going on, this time with the Wiznet W7100 microcontroller. 
A controller with a 8051 core and a build in TCPIPCore. 64 Kbytes flash, 64 Kbytes SRAM, 64 Kbytes TX/RX/TCPIP RAM, 256 Bytes data flash.
The W7100 has all Special Function Registers as a plain 8051 but there are special registers for the TCPIP-part.

What do we have to do?

We have to make a W7100.DAT file for Bascom-8051
We have to make an include-file for all W7100 registers
Get the LCD working
Get something out of the serial port
Get the three LED's blinking
Get the TCPIPCore working

 

Step 2: Creating the W7100.DAT

Used the existing REG51.DAT as a template.

Here the registers used in the REG51.DAT-file of Bascom-8051

REG51.DAT

Here the registers used in the W7100.DAT-file. In green the new ones.
 

W7100.DAT

In the DAT-file: In the [BIT]-section (all registers that ends with a 0 or a 8), all registers that can be manipulated by bit, and in the [BYTE]-section all others. In the [MISC]-section the name of the microcontroller:
up = W7100
a few interrupts
I_TF2 = 2B
I_INT2F = 43
I_INT3F = 4B
I_INT5F = 5B
I_WDIF = 63
the size of the internal RAM
IRAM = 256
The start of the program (jumping over the interrupt-vectors)
org = 66
and as last the clock
clockdiv = 1
 

Step 3: Getting the first test program in the W7100

 

We can test the W7100.DAT file with a small program to blink the three LEDs.

$regfile = "W7100.DAT"
$crystal = 11059200

Do
Set P0.3
Set P0.4
Set P0.5
Wait 1
Reset P0.3
Reset P0.4
Reset P0.5
Wait 1
Loop
End

We need WizISP to put the BIN or HEX file in the W7100.

Connect the iMCU7100 to a serial port on your computer, start the WizISP-program that can be found on the Wiznet-site. Put the BOOT-switch to the right (ON), power the board, select the right COM-port and open the port in the WizISP-program. When you have compiled the above example in Bascom-8051 you will have a HEX and a BIN-file. Load this file. You should see this:

With a push on AUTO your W7100 will be erased, blank checked, programmed and verified. And after all is well, it will start. You can leave the BOOT-switch to the right, but when you push the reset button the W7100 will stay in its boot loader. Putting the BOOT-switch to the left and pressing reset will restart the W7100.

If all is done correct you will see the three LEDs go on for 1 second, off for 1 second and that is repeated.

I have noticed it is very handy to minimize the WizISP program, every time you do a recompile of your Bascom-8051-program you will be noticed like this:

When you forget to switch the BOOT-switch to ON you will get an error-message. When you have, later on, HyperTerminal open, you will also get an error-message.

If you want every detail of the W7100-registers used, you could have a look here:

Tutorial Wiz810MJ I have written before.

 

Step 4: Get the LCD and serial working

Time for the real work, getting the LCD working. Have tested with the Bascom-8051 LCD-commands but it wasn't working. Have still to find why not. But remembered I wrote LCD-routines for the Siemens 80C535 before so used these. And also for the serial port, have to fill two registers to get it working. But don't worry you will see these are the only non-standard Bascom-8051 things to put in.


' second test with the Wiznet W7100

$regfile = "w7100.dat"
$crystal = 11059200
$baud = 115200
 

Put the next values in the registers to get the baudrate right


Tl1 = &HFC                                                                                     ' 115200 baud
Th1 = &HFE
 

Just for now, a few subroutines to drive the LCD


Declare Sub Lcd_reg(r As Byte)
Declare Sub Lcd_char(c As Byte)
Declare Sub Init_lcd

Dim R As Byte ' register
Dim C As Byte ' character
Dim D As Byte ' temporary
Dim Tekst As String * 20                                                            ' string tekst
Dim Pos As Integer
Dim Z As String * 1

Reset P0.1                                                                                    ' R/w LCD display
Reset P0.0

Call Init_lcd
 

After this line you should see something on your LCD


Print "Start"
 

And after this line you should see something on your terminal

In the next loop the three LEDs should be blinking


Do
Set P0.3
Set P0.4
Set P0.5
Wait 1
Reset P0.3
Reset P0.4
Reset P0.5
Wait 1
Print "X";
Loop
End


Sub Init_lcd
Waitms 15
Call Lcd_reg(&H30)
Waitms 4
Call Lcd_reg(&H30)
Waitms 1
Call Lcd_reg(&H30)
Waitms 4
Call Lcd_reg(&H20)
Waitms 1
Call Lcd_reg(&H20)
Call Lcd_reg(&H80)
Waitms 1
Call Lcd_reg(&H00)
Call Lcd_reg(&H80)
Waitms 1
Call Lcd_reg(&H00)
Call Lcd_reg(&Hc0)
Waitms 1
Call Lcd_reg(&H00)
Call Lcd_reg(&H10)
Waitms 1
Tekst = "W7100 and Bascom"
For Pos = 1 To Len(tekst)
Z = Mid(tekst , Pos , 1)
Call Lcd_char(asc(z))
Next Pos
End Sub

Sub Lcd_reg(r As Byte)
P2 = R
P0.2 = 1                                                                                'toggle E
Waitms 1
P0.2 = 0
End Sub


Sub Lcd_char(c As Byte)
P2 = C
P0.2 = 1
P0.0 = 1
Waitms 1
P0.2 = 0
P0.0 = 0
Waitms 1
Rotate C , Left , 4
P2 = C
P0.2 = 1
P0.0 = 1
Waitms 1
P0.2 = 0
P0.0 = 0
Waitms 1
End Sub

WizNet W7100 on the iMCU7100 evaluation board

 

Step 5: Include-file W7100.INC

We have to create an Include-file with all registers of the W7100 in it. If you have seen the W5100-include file for the Wiz810MJ-module you will see a lot of similarity.

W7100.inc

If we take a look at the TCPIPCore-memory-map: we see

FE0000-FE0034 Common Registers
FE4000-FE47FF Socket Registers
FE8000-FEBFFF TX memory
FEC000-FEFFFF RX memory

8 sockets can be used on the W7100 and it is real easy to figure out which registers belongs to which socket. Have a look at a part of the W7100.INC Bascom-8051 include file.

'Socket Mode register
Const w7100_S0_mr = &H4000
Const w7100_S1_mr = &H4100
Const w7100_S2_mr = &H4200
Const w7100_S3_mr = &H4300
Const w7100_S4_mr = &H4400
Const w7100_S5_mr = &H4500
Const w7100_S6_mr = &H4600
Const w7100_S7_mr = &H4700

'Channel Sn_CR register
Const w7100_S0_cr = &H4001
Const w7100_S1_cr = &H4101
Const w7100_S2_cr = &H4201
Const w7100_S3_cr = &H4301
Const w7100_S4_cr = &H4401
Const w7100_S5_cr = &H4501
Const w7100_S6_cr = &H4601
Const w7100_S7_cr = &H4701

'Channel interrupt register
Const w7100_S0_ir = &H4002
Const w7100_S1_ir = &H4102
Const w7100_S2_ir = &H4202
Const w7100_S3_ir = &H4302
Const w7100_S4_ir = &H4402
Const w7100_S5_ir = &H4502
Const w7100_S6_ir = &H4602
Const w7100_S7_ir = &H4702

'Channel status register
Const w7100_s0_sr = &H4003
Const w7100_s1_sr = &H4103
Const w7100_s2_sr = &H4203
Const w7100_s3_sr = &H4303
Const w7100_s4_sr = &H4403
Const w7100_s5_sr = &H4503
Const w7100_s6_sr = &H4603
Const w7100_s7_sr = &H4703
 

Step 6: Two routines to read and write in the TCPIPCore registers (FE0000-FEFFFF)

Here you see the external RAM of the W7100, 64 Kbytes SRAM, and 64 Kbytes for the TCPIP-core (including RX/TX buffers). Going over the C-examples I have seen the register DPX0 is used to gain access to this piece of memory.

WizNet W7100 on the iMCU7100 evaluation board

Have written two small subroutines to get access to the FE0000-FEFFFF part of the memory:

Sub W7100_write
Disable Interrupts
Dpx0 = &HFE
Out Adres , Value
Dpx0 = 0
Enable Interrupts
End Sub


Sub W7100_read
Disable Interrupts
Dpx0 = &HFE
Value = Inp(adres)
Dpx0 = 0
Enable Interrupts
End Sub

The 000000-00FFFF can be accessed through Bascom-8051 INP and OUT commands.

If you check the WIZMEMCPY.C routine on the CD, or website of Wiznet, you will see a routine to move a bulk of bytes from the lower part of RAM (Embedded RAM) to the RX/TX-buffers (TCPIPCore) and visa-versa. The adresspointers DPTR and DPTR1 are incremented or decremented simultaneous. I think the copy is done with a small routine that can be found in the boot loader. With the WCONF register access to the bootloader is managed. Registers DPX0/1, DPH0/1, DPL0/1 are used for this action.

Comments

Comments