Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Byte Variable = Byte Variable return error: source and targe

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
pinkfloyd11

Bascom Member



Joined: 02 Jul 2007
Posts: 247

italy.gif
PostPosted: Fri Mar 13, 2015 10:16 am    Post subject: Byte Variable = Byte Variable return error: source and targe Reply with quote

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
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2165

netherlands.gif
PostPosted: Fri Mar 13, 2015 11:59 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
pinkfloyd11

Bascom Member



Joined: 02 Jul 2007
Posts: 247

italy.gif
PostPosted: Fri Mar 13, 2015 12:48 pm    Post subject: Reply with quote

'////////////////////////////////////////////
' 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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6197
Location: Holland

blank.gif
PostPosted: Fri Mar 13, 2015 1:55 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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