BASCOM AVR RS485 PRINT/INPUT STRING PROBLEM - HELP!!!

Dier Sirs,

I’m programed in Bascom AVR-u RS485 communication between ATMEGA128 - master and ATMEGA32 - slave.

On Slave display have problem receive chr(240) as first character in string.

Test programs :

$regfile = “m128def.dat” 'Master

$crystal = 10000000

$hwstack = 32

$swstack = 20

$framesize = 40

$baud = 9600

Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2

Config Lcd = 16 * 2

Cls

Cursor Off

Config Com1 = 9600 , Synchrone = 0 , Parity = Even , Stopbits = 1 , Databits = 8 , Clockpol = 0 ’ MUST MATCH THE SLAVE

Dim S As String * 8 , S1 As String * 8

Config Print0 = Porte.2 , Mode = Set ’ use portd.2 for the direction

Rs485dir Alias Porte.2

Config Rs485dir = Output

'Rs485dir = 0 ’ go to receive mode

Rs485dir = 1

S = “08.03.11”

S1 = “13:12:58”

Lcd “RS485 sending.”

Wait 1

Do

Cls

Gosub Rs485_send

Loop

End

Rs485_send:

Rs485dir = 1

Print S

Print S1

Locate 1 , 1 : Lcd "S : " ; S

Locate 2 , 1 : Lcd "S1: " ; S1

Waitms 500

Return


$regfile = “m32def.dat” ’ slave

$crystal = 10000000

$baud = 19200

$hwstack = 32

$swstack = 40

$framesize = 40

$baud = 9600

Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Portd.6 , Rs = Portd.4

Config Lcd = 16 * 2

Cls

Cursor Off

Dim S As String * 8 , S1 As String * 8

Config Print0 = Portd.2 , Mode = Set ’ use portd.2 for the direction

Rs485dir Alias Portd.2

Config Rs485dir = Output

Rs485dir = 0 ’ go to receive mode

'Rs485dir = 1 ’ go to send mode

Lcd “RS485 receiving”

Wait 1

Do

Cls

Gosub Rs485_read

Loop

End

Rs485_read:

S = " "

S1 = " "

Input S

Input S1

Locate 1 , 1 : Lcd "S : " ; S

Locate 2 , 1 : Lcd "S1: " ; S1

Waitms 500

Return


On Slave LCD-u receive

S : chr(240)08.03.1 not received 08.03.11

S1: chr(240)13:12:5 not received 13:12:58

It would probably be in your best interest to fix it since you know you have a problem. Failing that, you might try asking a question.

I suggest you read the link in the forum announcement: viewtopic.php?f=14&t=27089

Before anyone looks at your code, you have to put it between ```


-Bill

Looking at the BASCOM-AVR help, it looks like you need to use

Config Print0 = Porte.2 , Mode = Set ' use portd.2 for the direction 
Rs485dir Alias Pine.2 ' Pine.2 instead of Porte.2
Config Rs485dir = Output

You also shouldn’t need to set the direction when sending. Bascom does that automatically.

Stig

Hi,

thank you, exactly what I’m looking for!