RS485 bufferelés és irányváltás
Ezt a bufferelést nem értem!
Így mind 2 UART-nak van Puffere?
Így mind 2 UART-nak van Puffere?
Kód: Egész kijelölése
'--- Alapadatok ---
$regfile = "M644def.dat" 'Chip
$crystal = 14745600 'Sebesség
$baud = 57600
'--- Foprogram ---
Dim Tstr As String * 40
Dim Num As Word , Mybaud As Word
Mybaud = 57600
Dim 485ad As Byte , 485vesz As Byte
485ad = 1
485vesz = 0
'open channel for output
Open "comd.7:Mybaud,8,n,1" For Output As #1
Open "comd.6:Mybaud,8,n,1" For Input As #2
Config Serialout = Buffered , Size = 200
Config Serialin = Buffered , Size = 200
Config Com1 = Buffered ' , Size = 20
Config Pind.5 = Output 'Max485 adat irány
Portd.5 = 485vesz
Do 'Vevö
Input Tstr
Print #1 ," text: " ; Tstr ;
Input Num
Print #1 , " number: " ; Num
Loop
'(
'Adó
Tstr = "Küldöt érték: "
Portd.5 = 485ad
Do 'Adó
For Num = 1 To 5000
Print Tstr
Waitms 1
Print Num
Waitms 1
Next Num
Loop
')
End????
Egyszerű.
Miért akarod megszakításba rakni? a buffer pont ezt csinálja....
A config serialin-t nézd meg.
A ByteMatch=all paraméterrel egy szubrutinra el is ugrik, amivel fel is dolgozhatod az adatot.
Számos belső paramétere van:
"The following internal variables will be generated :
_RS_HEAD_PTR0 , a byte counter that stores the head of the buffer
_RS_TAIL_PTR0 , a byte counter that stores the tail of the buffer.
_RS232INBUF0 , an array of bytes that serves as a ring buffer for the received characters.
_RS_BUFCOUNTR0, a byte that holds the number of bytes that are in the buffer."
Egyszerű.
Miért akarod megszakításba rakni? a buffer pont ezt csinálja....
A config serialin-t nézd meg.
A ByteMatch=all paraméterrel egy szubrutinra el is ugrik, amivel fel is dolgozhatod az adatot.
Számos belső paramétere van:
"The following internal variables will be generated :
_RS_HEAD_PTR0 , a byte counter that stores the head of the buffer
_RS_TAIL_PTR0 , a byte counter that stores the tail of the buffer.
_RS232INBUF0 , an array of bytes that serves as a ring buffer for the received characters.
_RS_BUFCOUNTR0, a byte that holds the number of bytes that are in the buffer."
Igen!
Pl.: Mega64. Mega128
ATmega164,-324
Pl.: Mega64. Mega128
ATmega164,-324
A hozzászólást 1 alkalommal szerkesztették, utoljára kapu48 2008. december 16. kedd, 21:02-kor.
Ám legyen:
Remarks
pin - The name of the PORT pin that is used to control the direction of an RS-485 driver.
mode - SET or RESET

Kód: Egész kijelölése
CONFIG PRINT0 = pin
CONFIG PRINT1 = pin
pin - The name of the PORT pin that is used to control the direction of an RS-485 driver.
mode - SET or RESET
Kód: Egész kijelölése
'------------------------------------------------------------------------------
'name : rs485.bas
'copyright : (c) 1995-2006, MCS Electronics
'purpose : demonstrates
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'------------------------------------------------------------------------------
$regfile = "m48def.dat" ' we use the M48
$crystal = 8000000
$baud = 19200
$hwstack = 32
$swstack = 32
$framesize = 32
Config Print0 = Portb.0 , Mode = Set
Config Pinb.0 = Output 'set the direction yourself
Dim Resp As String * 10
Do
Print "test message"
Input Resp ' get response
Loop
Egészen addig jól működöt a szimulátorban a programom, amíg az utolsó sort bele nem tettem! Pedig ez lenne a lényeg!
„ Print #1 , "test message " ; Tstr ; "Szám: " ; Num „ Itt elakad de, nem jelez semmi hibát!
Valami hibázik, vagy ezt nem tudja kezelni a szimulátor?
Irányváltás is működik. Bufferelést még nem tudom jó e így?

„ Print #1 , "test message " ; Tstr ; "Szám: " ; Num „ Itt elakad de, nem jelez semmi hibát!
Valami hibázik, vagy ezt nem tudja kezelni a szimulátor?
Kód: Egész kijelölése
$sim
$regfile = "m644def.dat" ' we use the M48
$crystal = 8000000
$baud = 19200
$hwstack = 32
$swstack = 32
$framesize = 32
Dim Tstr As String * 40
Tstr = ""
Dim Num As Word , Mybaud As Word
Num = 10
Mybaud = 57600
Config Com1 = Buffered
Config Print0 = Portd.5 , Mode = Reset
Config Pind.5 = Output 'set the direction yourself
'open channel for output and input
Open "comd.7:Mybaud,8,n,1" For Output As #1
Open "comd.6:Mybaud,8,n,1" For Input As #2
Dim Resp As String * 10
Tstr = "Küldöt érték: "
Do
Tstr = Inkey()
Print "test message " ; Tstr
' Input Resp
Print Num
Num = Inkey()
Print "Szám: " ; Num
Print #1 , "test message " ; Tstr ; "Szám: " ; Num
Loop