Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20564

BASCOM-AVR : Print HEX values UART : REPLY

$
0
0
Ok guys Im at a point to try a complete different approach about the Receive part.. I want to use the serial interrupt example, that receives byte per byte in.. That is no problem, i used that before.. but now i am using 2x Hardware uart and i use 2 stopbits.. how can i use the following example thats listenens to both uarts with 2 stopbits? [code:1:6407465809] '-------------------------------------------------------------------- ' SERINT.BAS ' (c) 1999-2005 MCS Electronics ' serial interrupt example for AVR ' also look at CONFIG SERIALIN for buffered input routines '-------------------------------------------------------------------- $regfile = "m88def.dat" $baud = 19200 $crystal = 8000000 Const Cmaxchar = 20 'number of characters Dim B As Bit 'a flag for signalling a received character Dim Bc As Byte 'byte counter Dim Buf As String * Cmaxchar 'serial buffer Dim D As Byte 'Buf = Space(20) 'unremark line above for the MID() function in the ISR 'we need to fill the buffer with spaces otherwise it will contain garbage Bc = 0 Print "Start" On Urxc Rec_isr 'define serial receive ISR Enable Urxc 'enable receive isr Enable Interrupts 'enable interrupts to occur Do If B = 1 Then 'we received something Disable Serial Print "{" ; Buf ; "}" 'print buffer Print "BC:" ; Bc 'print character counter 'now check for buffer full If Bc = Cmaxchar Then 'buffer full Buf = "" 'clear Bc = 0 'rest character counter End If Reset B 'reset receive flag Enable Serial End If Loop Rec_isr: D = Udr 'read UDR only once Print "*" ' show that we got here If Bc < Cmaxchar Then 'does it fit into the buffer? Incr Bc 'increase buffer counter If D = 13 Then 'return? Buf = Buf + Chr(0) Bc = Cmaxchar 'at the end Else Buf = Buf + Chr(d) 'add to buffer End If ' Mid(buf , Bc , 1) = Udr 'unremark line above and remark the line with Chr() to place 'the character into a certain position 'B = 1 'set flag End If B = 1 'set flag Return [/code:1:6407465809]

Viewing all articles
Browse latest Browse all 20564

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>