Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
$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 spaceDim A As Byte , S As String * 3 , Addresset(9) As Byte , Readdata(14) As Byte , Meter As Bit , Wifi As BitDim Addresdat(5) As String * 4 , Valor(5) As String * 1Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 1 ', SPIIN=valueDdrb.2 = 1Ddrb.1 = 1'Config Portb.1 = Output'Config Portb.2 = OutputAddresset(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 defaultAddresset(2) = &H00 'Valor de OPMODE a ser seteadoAddresset(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 defaultAddresset(4) = &H04 'Valor de MMODE a ser seteadoAddresset(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 defaultAddresset(6) = &H40 'Valor de OPMODE a ser seteadoAddresset(7) = &H13Addresset(Cool = &H14Addresset(9) = &H23Prob:Wait 1Set Portb.1Set Portb.2Display OnClsLcd "Luis Mena"Locate 2 , 4 : Lcd "Poli"Wait 2For A = 1 To 10Shiftlcd Right 'shift the text to the rightWait 1 'wait a momentNextSpiinitReset Portb.2Spiout Addresset(7) , 1Set Portb.2Reset Portb.2Spiin Readdata(1) , 1Set Portb.2Waitms 100Set Portb.2Spiout Addresset(Cool , 1Set Portb.2Reset Portb.2Spiin Readdata(2) , 1Set Portb.2Reset Portb.2Spiout Addresset(9) , 1Set Portb.2Reset Portb.2Waitms 1Set Portb.2Reset Portb.2Spiin Readdata(3) , 1Set Portb.2Reset Portb.2Spiout Addresset(7) , 1Set Portb.2Reset Portb.2Spiin Readdata(4) , 1Set Portb.2ClsFor A = 1 To 4Addresdat(a) = Hex(readdata(a))Valor(a) = Str(a)Locate A , 2 : Lcd "Valor"Lcd Valor(a)Lcd Addresdat(a)Wait 1Next AWait 10ClsLocate 1 , 4 : Lcd "Pruebas"S = Str(a)Lcd SWait 3'SpiinitSpiout Addresset(1) , 6Spiout Addresset(7) , 1Waitms 1Spiin Readdata(1) , 1Waitms 1Spiout Addresset(Cool , 1Spiin Readdata(2) , 1Spiout Addresset(9) , 1Waitms 1Spiin Readdata(3) , 1Waitms 1Spiout Addresset(7) , 1Spiin Readdata(4) , 1ClsFor A = 1 To 4Addresdat(a) = Hex(readdata(a))Valor(a) = Str(a)Locate A , 2 : Lcd "Valor"Lcd Valor(a)Lcd Addresdat(a)Wait 1Next AWait 10Goto Prob
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?
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.