+ Reply to Thread
Results 1 to 3 of 3
Thread: Serin2 data bits
-
- 20th February 2009, 23:10 #1
Serin2 data bits
Does anyone know how to change the serin2 bits without using the DEFINE SER2_BITS command?
Almost 100% of the time I am receiving 8-none, 7 odd, or 7 even, so I use the regular commands and just clear the parity bit. I would like to add the option of selecting at run time either 7-None or 8-odd/Even, and again I would ignore the parity.
Also, once I'm in 9 bit mode, and I'm receiving data into a byte array, how is the 9th bit handled. I know the HSERIN command has a special register for the 9th bit.
Thanks, David
-
- 12th February 2019, 03:29 #2
Re: Serin2 data bits
Almost 10 years to the day I decide to go to the forum to see if I can find help with this problem and find my old empty thread. Can anyone direct me to a way to change to 7 none, 8 odd or 8 even for serial data. I use Serin2 with 8 databit no parity almost all the time but I would like to give my customers the option to do the less common stuff if they want to change it in the field. The only thought I have so far is use my normal commands unless the option is set and then I can use HSERIN instead, but even then I think that only allows me to add the ability to do 8 data bits with aprity not 7 with none. Anyone else do something similar where they allow the customer to select their baud databits and parity at run time?
-
- 12th February 2019, 16:34 #3
Re: Serin2 data bits
Within PBP you can manually manipulate SFRs, read and write to UART registers, etc. If the PIC you are using has EEPROM, you can set up an array of sequential EEPROM addresses with SFR settings. It would default to address 0 of the array. If different settings are desired, a SELECT CASE can find the EEPROM address that matches the settings, then a READ from the EEPROM to the UART SFR would configure appropriately. If you need to add a 9th bit, or something else that won't automatically convert when you reconfigure the UART register, manually loading the TXREG and reading the RXREG will enable full flexibility.
Here is a piece of code I use to talk with a Nextion display screen using UART on a PIC18F47K42:
Code:for b0 = 0 to 6 ;Send 7 ASCii Characters via UART LOOKUP b0,["n0.val="],b1 ;Rotate through text DO LOOP UNTIL U1FIFO.5 = 1 ;Wait until TXREG is empty U1TXB = b1 ;Send next character next b0 DO LOOP UNTIL U1FIFO.5 = 1 ;Wait until TXREG is empty U1TXB = $22 ;ASCii Double Quotes: " ARRAYWRITE HhDcA, [#HhDc] IF HhDc < 100 THEN HhDcA[2] = HhDcA[1] HhDcA[1] = HhDcA[0] HhDcA[0] = " " ENDIF IF HhDc < 10 THEN HhDcA[2] = HhDcA[1] HhDcA[1] = " " HhDcA[0] = " " ENDIF DO LOOP UNTIL U1FIFO.5 = 1 ;Wait until TXREG is empty U1TXB = HhDcA[0] DO LOOP UNTIL U1FIFO.5 = 1 ;Wait until TXREG is empty U1TXB = HhDcA[1] DO LOOP UNTIL U1FIFO.5 = 1 ;Wait until TXREG is empty U1TXB = HhDcA[2] DO LOOP UNTIL U1FIFO.5 = 1 ;Wait until TXREG is empty U1TXB = $22 ;ASCii Double Quotes: " for b0 = 1 to 3 DO LOOP UNTIL U1FIFO.5 = 1 ;Wait until TXREG is empty U1TXB = $FF ;$FF, $FF, $FF; End of Transmission next b0
Similar Threads
-
Using Nokia LCD
By BobP in forum mel PIC BASIC ProReplies: 300Last Post: - 3rd May 2018, 04:47 -
Big characters on HD44780 4x20
By erpalma in forum mel PIC BASIC ProReplies: 23Last Post: - 7th January 2007, 03:21 -
LCD + bar graph
By DynamoBen in forum mel PIC BASIC ProReplies: 13Last Post: - 5th October 2005, 14:50 -
error on compiling
By parker in forum mel PIC BASIC ProReplies: 0Last Post: - 16th June 2005, 14:31 -
Sinus calculating !
By Don Mario in forum mel PIC BASIC ProReplies: 29Last Post: - 29th November 2004, 00:56
Bookmarks