Initialize with Python and Beaglebone WIZ812MJ

#1

I was trying all day to initialize the module with a BBB and SPI (3.3v levels BBB to WIZ812MJ)
I didn’t the last testing converting the levels to 5v for WIZ812MJ sides, because i believe that WIZ812MJ accepts 3.3v.

Spi loopback works.

Here my code.

#!/usr/bin/python

import time
#import Adafruit_BBIO.GPIO as GPIO
from spi import SPI


#SPI config
spi1 = SPI(1, 0)
spi1.msh = 4000000
spi1.mode = 0
spi1.bpw= 8
spi1.lsbfirst = True
spi1.open(1,0)


#loopback testing cables DI <---> D0
#print spi1.xfer2( [32, 11, 110, 22, 220]  )

def write_reg( addr, data):
	#print  spi1.cshigh
	FIRSTBYTE = addr >> 8
        SECONDBYTE = addr << 8
        spi1.writebytes( [ 0xF0, FIRSTBYTE, SECONDBYTE, addr ] ) #READ
	
def read_reg( addr ):
	FIRSTBYTE = addr >> 8
	SECONDBYTE = addr << 8
	spi1.writebytes( [ 0x0F, FIRSTBYTE, SECONDBYTE, addr ] ) #READ
	retval = spi1.readbytes(1)
	#print "read data= ", retval
	return retval


write_reg( 0x0000, 0x80 )   # INIT SW RESET;

print "REG BEFORE=", read_reg( 0x000F )

write_reg( 0x0016, 0x00 ) #irq disable
write_reg( 0x0017, 0xD0 ) #timeout
write_reg( 0x0019, 0x08 ) #retrans to 8

# GW
write_reg( 0x0001, 0x0A ) 
write_reg( 0x0002, 0x6D )
write_reg( 0x0003, 0x00 )
write_reg( 0x0004, 0x01 )

#mask
write_reg( 0x0005, 0xFF ) 
write_reg( 0x0006, 0xFF )
write_reg( 0x0007, 0xFF )
write_reg( 0x0008, 0x00 )

#set MAC BD-C3-57-AA-49-C3
write_reg( 0x0009, 0xBD )
write_reg( 0x000A, 0xC3 )
write_reg( 0x000B, 0x57 )
write_reg( 0x000C, 0xAA )
write_reg( 0x000D, 0x49 )
write_reg( 0x000E, 0xC3 )

#set IP address 10.109.0.112   
write_reg( 0x000F, 0x0A )
write_reg( 0x0010, 0x6D )
write_reg( 0x0011, 0x00 )
write_reg( 0x0012, 0x70 )

write_reg( 0x001A, 0x55 ) # socket mem
write_reg( 0x001B, 0x55 ) # mem sockets transmm


print "REG AFTER:", read_reg( 0x000F )


spi1.close()

Any idea?

#2

Hi,
As I know, WIZ812MJ operates 3.3 voltage with 5V IO-tolerence.
I don’t know why did you need a level shifter.

Thank you.