Habs selbst hinbekommen.
Falls jemand auch dieses Problem hat, hier der Code.
Ist zwar alles zu Fuss gemacht und viel Text, aber es läuft einwandfrei.
Code:
'....General Settings
$regfile = "m162def.dat"
'************************** USART0 GLOBALS *************************
'*
Dim Usart0_control_a As Byte
Dim Usart0_control_b As Byte
Dim Usart0_control_c As Byte
'*
'************************** USART1 ALIASES *************************
'*
Rxc_0 Alias Usart0_control_a.7 '[R ] receive complete
Txc_0 Alias Usart0_control_a.6 '[R/W] transmit complete
Dre_0 Alias Usart0_control_a.5 '[R ] data register empty
Fre_0 Alias Usart0_control_a.4 '[R ] frame error
Dor_0 Alias Usart0_control_a.3 '[R ] data overrun
Par_0 Alias Usart0_control_a.2 '[R ] parity error
U2x_0 Alias Usart0_control_a.1 '[R/W] x2 transmission speed
Mpc_0 Alias Usart0_control_a.0 '[R/W] multiprocessor communication mode
Rxcie_0 Alias Usart0_control_b.7 '[R/W] receive complete interrupt enable
Txcie_0 Alias Usart0_control_b.6 '[R/W] transmit complete interrupt enable
Dreie_0 Alias Usart0_control_b.5 '[R/W] data register empty interrupt enable
Rxcen_0 Alias Usart0_control_b.4 '[R/W] receiver enable
Txcen_0 Alias Usart0_control_b.3 '[R/W] transmitter enable
Cscz2_0 Alias Usart0_control_b.2 '[R/W] character size select bit 3
Urxb8_0 Alias Usart0_control_b.1 '[R ] received data bit 8 (for 9-bit communications... must be inspected before data register)
Utxb8_0 Alias Usart0_control_b.0 '[R/W] transmit data bit 8 (for 9-bit communications... must be written before writing data register)
Resrv_0 Alias Usart0_control_c.7 '[R/W] reserved bit for future use... set to 0
Async_0 Alias Usart0_control_c.6 '[R/W] asnyc / sync select.... 0 = async, 1 = sync
Parm1_0 Alias Usart0_control_c.5 '[R/W] parity mode select bit 1
Parm0_0 Alias Usart0_control_c.4 '[R/W] parity mode select bit 0
Stopb_0 Alias Usart0_control_c.3 '[R/W] stop bit select... 0 = 1 stop bit, 1 = 2 stop bits
Cscz1_0 Alias Usart0_control_c.2 '[R/W] character size select bit 1
Cscz0_0 Alias Usart0_control_c.1 '[R/W] character size select bit 0
Ucpol_0 Alias Usart0_control_c.0 '[R/W] clock polarity for synchronous operation
'************************** USART1 GLOBALS *************************
'*
Dim Usart1_control_a As Byte
Dim Usart1_control_b As Byte
Dim Usart1_control_c As Byte
'*
'************************** USART1 ALIASES *************************
'*
Rxc_1 Alias Usart1_control_a.7 '[R ] receive complete
Txc_1 Alias Usart1_control_a.6 '[R/W] transmit complete
Dre_1 Alias Usart1_control_a.5 '[R ] data register empty
Fre_1 Alias Usart1_control_a.4 '[R ] frame error
Dor_1 Alias Usart1_control_a.3 '[R ] data overrun
Par_1 Alias Usart1_control_a.2 '[R ] parity error
U2x_1 Alias Usart1_control_a.1 '[R/W] x2 transmission speed
Mpc_1 Alias Usart1_control_a.0 '[R/W] multiprocessor communication mode
Rxcie_1 Alias Usart1_control_b.7 '[R/W] receive complete interrupt enable
Txcie_1 Alias Usart1_control_b.6 '[R/W] transmit complete interrupt enable
Dreie_1 Alias Usart1_control_b.5 '[R/W] data register empty interrupt enable
Rxcen_1 Alias Usart1_control_b.4 '[R/W] receiver enable
Txcen_1 Alias Usart1_control_b.3 '[R/W] transmitter enable
Cscz2_1 Alias Usart1_control_b.2 '[R/W] character size select bit 3
Urxb8_1 Alias Usart1_control_b.1 '[R ] received data bit 8 (for 9-bit communications... must be inspected before data register)
Utxb8_1 Alias Usart1_control_b.0 '[R/W] transmit data bit 8 (for 9-bit communications... must be written before writing data register)
Resrv_1 Alias Usart1_control_c.7 '[R/W] reserved bit for future use... set to 0
Async_1 Alias Usart1_control_c.6 '[R/W] asnyc / sync select.... 0 = async, 1 = sync
Parm1_1 Alias Usart1_control_c.5 '[R/W] parity mode select bit 1
Parm0_1 Alias Usart1_control_c.4 '[R/W] parity mode select bit 0
Stopb_1 Alias Usart1_control_c.3 '[R/W] stop bit select... 0 = 1 stop bit, 1 = 2 stop bits
Cscz1_1 Alias Usart1_control_c.2 '[R/W] character size select bit 1
Cscz0_1 Alias Usart1_control_c.1 '[R/W] character size select bit 0
Ucpol_1 Alias Usart1_control_c.0 '[R/W] clock polarity for synchronous operation
'... Einstellungen für Com1
Reset Async_0
Reset U2x_0
Set Rxcen_0
Set Txcen_0
Reset Rxcie_0
Reset Txcie_0
Set Resrv_0
Reset Cscz2_0
Set Cscz1_0
Set Cscz0_0
Set Parm1_0
Reset Parm0_0
Reset Stopb_0
Reset Mpc_0
Ucsr0a = Usart0_control_a
Ucsr0b = Usart0_control_b
Ucsr0c = Usart0_control_c
Reset Ucsr0c.7
'... Einstellungen für Com2
Reset Async_1
Reset U2x_1
Set Rxcen_1
Set Txcen_1
Reset Rxcie_1
Reset Txcie_1
Set Resrv_1
Reset Cscz2_1
Set Cscz1_1
Set Cscz0_1
Set Parm1_1
Reset Parm0_1
Reset Stopb_1
Reset Mpc_1
Ucsr1a = Usart1_control_a
Ucsr1b = Usart1_control_b
Ucsr1c = Usart1_control_c
Reset Ucsr1c.7
$crystal = 18432000
$baud1 = 115200
$baud = 115200
Do
Waitms 100
Open "COM1:" For Random As #1
Open "COM2:" For Random As #2
Print #1 , "Text via Com1"
Print #2 , "Text via Com2"
Close #1
Close #2
Loop
end
Lesezeichen