View previous topic :: View next topic |
Author |
Message |
pinkfloyd11
Joined: 02 Jul 2007 Posts: 247
|
Posted: Fri Mar 13, 2015 10:16 am Post subject: Byte Variable = Byte Variable return error: source and targe |
|
|
Hello
I need to set some bits in a byte and after send it.
More precisely I need to set bit 7 of Byte_to_send.
But I give back this:
Error : 242 Line : 90 Data type of source and target variables do not match [ 0] , in File : E:\Dropbox\....Firmware\Test Comandi Singoli\Test Comandi Singoli.bas
What is wrong?
Code: | Sub CC1101_Read_Value(ByVal Register_Address as Byte)
Local Byte_to_send as Byte
Local Received_Byte as Byte
'Costruisco il Byte da Inviare secondo la struttura
'[7] := Header 1
'[6] := Burst 0
'[5-0] := Indirizzo Registro
Byte_to_send = Register_Address
SET Byte_to_Send.7
SPIout Byte_to_send,1
SPIin Received_Byte,1
Print "LETTO = "; Byte_Ricevuto
End Sub
| (BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Fri Mar 13, 2015 11:59 am Post subject: |
|
|
Hi,
This compiles fine with 2078.
Give me a complete not working sample. With only the SUB it's hard to debug.
Code: |
$regfile = "M88def.dat"
$crystal = 8000000
$baud = 19200
$hwstack = 128
$swstack = 128
$framesize = 128
declare Sub CC1101_Read_Value(ByVal Register_Address as Byte)
Dim A As Byte
Config Spi = Soft , Din =Pinb.0 , Dout =Portb.1 , Ss =Portb.2 , Clock =Portb.3
Spiinit
Do
call CC1101_Read_Value(123)
Loop
End
Sub CC1101_Read_Value(ByVal Register_Address as Byte)
Local Byte_to_send as Byte
Local Received_Byte as Byte
'Costruisco il Byte da Inviare secondo la struttura
'[7] := Header 1
'[6] := Burst 0
'[5-0] := Indirizzo Registro
Byte_to_send = Register_Address
SET Byte_to_Send.7
SPIout Byte_to_send,1
SPIin Received_Byte,1
End Sub
|
_________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
pinkfloyd11
Joined: 02 Jul 2007 Posts: 247
|
Posted: Fri Mar 13, 2015 12:48 pm Post subject: |
|
|
'////////////////////////////////////////////
' SPI SEND COMMAND
'////////////////////////////////////////////
'*********************************
'Direttive al compilatore
'*********************************
$regfile = "m328pdef.dat"
$hwstack = 32
$swstack = 32
$framesize = 32
$crystal = 16000000
$baud = 57600
'*********************************
$Include "CC1101 REGISTER.inc"
CONFIG SUBMODE = NEW
CONFIG Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 16
SPIINIT
Declare Sub CC1101_Init
Declare Sub CC1101_Read_Value(byval Register As Byte)
Declare Sub CC1101_Write_Value(byval Register As Byte , Byval Value As Byte)
Declare Sub CC1101_Reset
Dim Carattere_ASCII as Byte
PRINT " -- TEST SPI COMMAND MENU --"
PRINT "1) READ CONFIG REGISTER"
PRINT "2) READ STATUS REGISTER"
PRINT ""
PRINT ""
DO
Carattere_ASCII = Inkey() 'get ascii value from serial port
If Carattere_ASCII > 0 Then
Print "ASCII = " ; Carattere_ASCII
End If
SELECT CASE Carattere_ASCII
CASE 49
PRINT "READ CONFIG REGISTER"
CC1101_Read_Value(&H0030)
CASE 50
PRINT "READ STATUS REGISTER"
CASE 51
CASE 52
END SELECT
LOOP
'_______________________________________________________________________________________
Sub CC1101_Init()
End Sub
'_______________________________________________________________________________________
Sub CC1101_Read_Value(ByVal Register_Address as Byte)
Local Byte_to_Send as Byte
Local Byte_Received as Byte
Byte_to_Send = 0
Byte_Received = 0
'Costruisco il Byte da Inviare secondo la struttura
'[7] := Header 1
'[6] := Burst 0
'[5-0] := Indirizzo Registro
Byte_to_Send = Register_Address
SET Byte_to_Send .7
SPIout Byte_to_Send , 1
SPIin Byte_Received , 1
Print "BYTE READ = "; Byte_Received
End Sub
'_______________________________________________________________________________________
Sub CC1101_Write_Value(Register , Value )
End Sub
'_______________________________________________________________________________________
Sub CC1101_Reset
End Sub
'_______________________________________________________________________________________ |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Mar 13, 2015 1:55 pm Post subject: |
|
|
you have :
Declare Sub CC1101_Init
Declare Sub CC1101_Read_Value(byval Register As Byte)
Declare Sub CC1101_Write_Value(byval Register As Byte , Byval Value As Byte)
Declare Sub CC1101_Reset
and then check the implementation, it differs !
when using submode=new, you do not need the DECLARE , just put the sub/function before you call it, for example using an include file.
when you do use declare sub, make sure the declare matches the implementation. _________________ Mark |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|