Bascom AVR

poruka: 1
|
čitano: 3.258
|
moderatori: Lazarus Long, XXX-Man, vincimus
1
+/- sve poruke
ravni prikaz
starije poruke gore
17 godina
neaktivan
offline
Problem komunikacija RS485 PRINT/INPUT string !!!!

Napisao sam u Bascom AVR-u test program RS485 comunikacija između ATMEGA128 - master and ATMEGA32 - slave. 
Na Slave LCD-u uvijek dobijem chr(240) kao prvo slovo u stringu.

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

************************************* 
Na Slave LCD-u imam ispis

 
S : chr(240)08.03.1 umjesto 08.03.11
S1: chr(240)13:12:5 umjesto 13:12:58

Unaprijed se zahvaljujem na odgovoru.

 
0 0 hvala 0
1
Nova poruka
E-mail:
Lozinka:
 
vrh stranice