Hi, I've been trying a million different ways to read a very simple 8 bit internal register of the ADE7758 (the die version) and display it on lcd, but so far all I am getting on the LCD is FF.
I am 100% sure on the the hardware as I have checked them many times, they are correct and working properly. both ICs are OK as well. I am posting my code here, hope I am doing it in the correct forum:
[code:1:c0f8aaca8d]
$regfile = "m8def.dat"
$crystal = 10000000 '10000000
$baud = 9600
$hwstack = 32
$swstack = 10
$framesize = 40
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 1 , Clockrate = 4 , Noss = 1 , Spiin = 255
Dim Readdata As Byte , Address As Word , Wrt_adrs As Byte , Opmode(2) As Byte , I As Integer
Config Lcdpin = Pin , Db4 = Pinc.2 , Db5 = Pinc.3 , Db6 = Pinc.4 , Db7 = Pinc.5 , E = Pinc.1 , Rs = Pinc.0
Config Lcd = 16 * 2
Cursor Off : Cls
Locate 1 , 1 : Lcd "ALPA . "
Locate 2 , 1 : Lcd "Version 14.8 "
Wait 2
'-------------------------------------------------------------------
Config Portb.5 = Output ' sck
Config Portb.3 = Output 'MOSI
Config Portb.2 = Output 'SS
Config Portb.4 = Input
Ss Alias Portb.2
I = 1
Address = &H7F
Wrt_adrs = &HFF
Opmode(1) = &H13
Opmode(2) = &B01000000
Spiinit
Do
Cls
Reset Ss
Spiout Wrt_adrs , 1
Spiout Address , 1
Spiin Readdata , 1
Readdata = Spimove(address)
Lcd "Value = " ; Hex(readdata)
Locate 2 , 1 : Lcd I ; " Loops"
Wait 1
Set Ss
I = I + 1
Waitms 200
Loop
[/code:1:c0f8aaca8d]
Please help me out, I am absolutely clueless what could be wrong
Thank you very much in advance
I have also attached the ADE7758 datasheet.
[b:c0f8aaca8d][color=red:c0f8aaca8d](BASCOM-AVR version : 1.11.9.8 , Latest : 2.0.7.6 )[/b:c0f8aaca8d][/color:c0f8aaca8d]
↧