Hi,
I use an atmega1284 with a 16Mhz oscillator ..
if I use a baud rate of 9600, I have problems receiving the first character sent ... why?
Alles anzeigen
I use an atmega1284 with a 16Mhz oscillator ..
if I use a baud rate of 9600, I have problems receiving the first character sent ... why?
Quellcode
- $regfile = "m1284def.dat"
- $crystal = 16000000
- $baud = 9600
- '**************
- Config Lcdpin = Pin , Db4 = Porta.3 , Db5 = Porta.2 , Db6 = Porta.1 , Db7 = Porta.0 , E = Portc.5 , Rs = Portc.6
- Config Lcd = 16 * 2
- '**************
- Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
- Config Serialin = Buffered , Size = 254
- Config Portd.6 = Output 'BUZZER
- Buzzer Alias Portd.6
- Declare Sub Bip
- Dim Rx_cmd , Ric As Byte
- Dim Command As String * 254
- Enable Interrupts
- Waitms 30
- Initlcd
- Cls
- locate 1,1
- lcd "HELLO"
- bip
- Command = ""
- Ric = 0
- Rx_cmd = 0
- do
- Rx_cmd = Ischarwaiting() 'CONTROLLA SE E' STATO RICEVUTO UN CARATTERE
- If Rx_cmd = 1 Then
- Rx_cmd = Waitkey() 'RITORNA IL VALORE DECIMALE RICEVUTO
- Ric = 1
- Command = Command + Chr(rx_cmd) 'INSERISCE I CARATTERI IN UNA STRINGA FINO A QUANDO LA TRASMISSIONE NON TERMINA
- Waitms 1
- Else
- If Ric = 1 Then
- Bip
- Ric = 0
- Cls
- Locate 2 , 1
- Lcd Command
- Command = ""
- End If
- End If
- loop
- Sub Bip
- Buzzer = 0
- Waitms 20
- Buzzer = 1
- End Sub
- end