cerberolooch
Newbie level 2
Hi, how’s going. I’ve a really big problem with the SPI communication. I’m using the atmega8, I’ve tried to use atmega48 but I don’t know way but even the simulation doesn’t work at all.
I’m programming on Bascom. So far the simulation, which I’ve been doing it on Proteus(ISIS), works perfectly, but once I try on hardware it doesn’t work.
I’ve checked about the fuse bits for programming, and it looks like is ok. I had used extreme burner and progisp in order to program the mu. But there is always the same mistake (there is not SPI communication, no even the signals on miso, mosi, sck,etc, im using a oscilloscope to see that).
Here I left my testing code (on bascom), please check it and tell me if something is wrong.
Something about I’m starting to doubt about is, if it’s ok to use the hardware SPI communication, ‘cause its use to program the mu. Please help.
A really important Question, if I´m using my mU as a master, doesn’t matter if it is or not connected with a slave or other spi devise, it should have and show the miso, mosi, sck signals, isn’t it?
If somebody wants more info about the program I’d send u my testing program, simulation on ISIS, please check it and if u find something wrong please let me know
PD: the project in the future has to use this communication with the ADE7758 and with a WIFI module, so the most important by now is to have the spi communication.
I’m programming on Bascom. So far the simulation, which I’ve been doing it on Proteus(ISIS), works perfectly, but once I try on hardware it doesn’t work.
I’ve checked about the fuse bits for programming, and it looks like is ok. I had used extreme burner and progisp in order to program the mu. But there is always the same mistake (there is not SPI communication, no even the signals on miso, mosi, sck,etc, im using a oscilloscope to see that).
Here I left my testing code (on bascom), please check it and tell me if something is wrong.
Something about I’m starting to doubt about is, if it’s ok to use the hardware SPI communication, ‘cause its use to program the mu. Please help.
A really important Question, if I´m using my mU as a master, doesn’t matter if it is or not connected with a slave or other spi devise, it should have and show the miso, mosi, sck signals, isn’t it?
If somebody wants more info about the program I’d send u my testing program, simulation on ISIS, please check it and if u find something wrong please let me know
PD: the project in the future has to use this communication with the ADE7758 and with a WIFI module, so the most important by now is to have the spi communication.
Code:
$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