$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
Dim A As Byte , S As String * 3 , Addresset(9) As Byte , Readdata(14) As Byte , Meter As Bit , Wifi As Bit
Dim Addresdat(5) As String * 4 , Valor(5) As String * 1
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 1 ', SPIIN=value
Ddrb.2 = 1
Ddrb.1 = 1
'Config Portb.1 = Output
'Config Portb.2 = Output
Addresset(1) = &H93 'address de OPMODE (ojo ya esta con el MCB en 1 para escritura a esta address, original h13) a ser seteada, ojo la direccion de WAVMODE es 0x15 pero la voy a dejar con del set default
Addresset(2) = &H00 'Valor de OPMODE a ser seteado
Addresset(3) = &H94 'address de MMODE (ojo ya esta con el MCB en 1 para escritura a esta address, origina h14)a ser seteada, ojo la direccion de COMPMODE es 0x16 pero la voy a dejar con del set default
Addresset(4) = &H04 'Valor de MMODE a ser seteado
Addresset(5) = &HA3 'address de GAIN (ojo ya esta con el MCB en 1 para escritura a esta address, original h23)a ser seteada,esta dierccion posee los valoers de ganacia y escala de I y V en al PGA ojo la direccion de LCYCMODE es 0x17 pero la voy a dejar con del set default
Addresset(6) = &H40 'Valor de OPMODE a ser seteado
Addresset(7) = &H13
Addresset(Cool = &H14
Addresset(9) = &H23
Prob:
Wait 1
Set Portb.1
Set Portb.2
Display On
Cls
Lcd "komodo"
Locate 2 , 4 : Lcd "Poli"
Wait 2
For A = 1 To 10
Shiftlcd Right 'shift the text to the right
Wait 1 'wait a moment
Next
Spiinit
Reset Portb.2
Spiout Addresset(7) , 1
Set Portb.2
Reset Portb.2
Spiin Readdata(1) , 1
Set Portb.2
Waitms 100
Set Portb.2
Spiout Addresset(Cool , 1
Set Portb.2
Reset Portb.2
Spiin Readdata(2) , 1
Set Portb.2
Reset Portb.2
Spiout Addresset(9) , 1
Set Portb.2
Reset Portb.2
Waitms 1
Set Portb.2
Reset Portb.2
Spiin Readdata(3) , 1
Set Portb.2
Reset Portb.2
Spiout Addresset(7) , 1
Set Portb.2
Reset Portb.2
Spiin Readdata(4) , 1
Set Portb.2
Cls
For A = 1 To 4
Addresdat(a) = Hex(readdata(a))
Valor(a) = Str(a)
Locate A , 2 : Lcd "Valor"
Lcd Valor(a)
Lcd Addresdat(a)
Wait 1
Next A
Wait 10
Cls
Locate 1 , 4 : Lcd "Pruebas"
S = Str(a)
Lcd S
Wait 3
'Spiinit
Spiout Addresset(1) , 6
Spiout Addresset(7) , 1
Waitms 1
Spiin Readdata(1) , 1
Waitms 1
Spiout Addresset(Cool , 1
Spiin Readdata(2) , 1
Spiout Addresset(9) , 1
Waitms 1
Spiin Readdata(3) , 1
Waitms 1
Spiout Addresset(7) , 1
Spiin Readdata(4) , 1
Cls
For A = 1 To 4
Addresdat(a) = Hex(readdata(a))
Valor(a) = Str(a)
Locate A , 2 : Lcd "Valor"
Lcd Valor(a)
Lcd Addresdat(a)
Wait 1
Next A
Wait 10
Goto Prob