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