16F88 7 data bits


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2005
    Posts
    74

    Default 16F88 7 data bits

    I have to set up for 9600, 7,N,1 and I do see the defines in PBP :
    Define SER_BITS 7 But I need to be able to do it during runtime.

    I don't understand how to do it using the 16F88 Datasheet.
    I know how to do the Baud Rate during runtime as I've done that many times.

    Richard
    Last edited by rwskinner; - 12th February 2008 at 03:21.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rwskinner View Post
    I have to set up for 9600, 7,N,1 and I do see the defines in PBP :
    Define SER_BITS 7 But I need to be able to do it during runtime.

    I don't understand how to do it using the 16F88 Datasheet.
    I know how to do the Baud Rate during runtime as I've done that many times.

    Richard
    Are you saying that you have to switch back and forth between 8N1 and 7N1?
    Short of writing your own serial routines, I don't see it happening with PBP.

    A thought (if in fact it's not possible to switch between 7N1 and 8N1), how about putting a 'hijacking' PIC in between the receiving PIC and the sending device to receive 7N1 in software and send out 8N1 in hardware....a sort of buffering translator...I can see a 16F628A doing that rather easily.

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    >>Define SER_BITS 7

    I think you mean DEFINE SER2_BITS 7 and this is for software Serial Out (not Hardware) so the data sheet will not help in this case. The hardware UART (on all PICs?) does not support 7N1.

    Something to try: two adjacent pins connected together ... set one for output using SEROUT 8N1. Set the adjacent pin for output using SEROUT2 7N1. Make the pin not in use an input - switch back and forth as needed. You also could use the USART for the 8N1 rather than SEROUT. You might need weak pullups (or pulldowns if inverted mode) to ensure the serial line is not corrupted when you switch between pins.

    Good Luck
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    >>Define SER_BITS 7

    I think you mean DEFINE SER2_BITS 7 and this is for software Serial Out (not Hardware) so the data sheet will not help in this case. The hardware UART (on all PICs?) does not support 7N1.

    Something to try: two adjacent pins connected together ... set one for output using SEROUT 8N1. Set the adjacent pin for output using SEROUT2 7N1. Make the pin not in use an input - switch back and forth as needed. You also could use the USART for the 8N1 rather than SEROUT. You might need weak pullups (or pulldowns if inverted mode) to ensure the serial line is not corrupted when you switch between pins.

    Good Luck
    I thought the DEFINE for SERIN/SEROUT stuck constant for the whole program...like you can't re-DEFINE it.

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by skimask View Post
    I thought the DEFINE for SERIN/SEROUT stuck constant for the whole program...like you can't re-DEFINE it.
    They do - that is why I suggested using SEROUT for one and SEROUT2 for the other. They are not related by the defines
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  6. #6
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Yes, two protocols jumper selectable. When I power up, I check the jumper then use the proper protocol. Modbus ASCII 9600,N,7,1 or Modbus RTU 9600,N,8,1. The device needs to be changed on the fly depending on the equipment it's being hooked to.

    I know my CCS Compiler allows these settings but the project is an existing PBP project. I hate to have to convert it all.

    Quote Originally Posted by skimask View Post
    Are you saying that you have to switch back and forth between 8N1 and 7N1?
    .

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    They do - that is why I suggested using SEROUT for one and SEROUT2 for the other. They are not related by the defines
    AHA! Missed that!

  8. #8
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    In the software serial routines, MELabs must be looking at the settings in order to determine how to send the data bits and set the parity right? Problem is it's a define and not a variable or it most likely could be changed on the fly.

    I sure hate to bit bang this but I may have to.

    Richard

  9. #9
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    >>I sure hate to bit bang this but I may have to.

    you do not have to, PBP has done the work for you.

    >>two adjacent pins connected together

    another thought - no need for adjacent pins - use SEROUT for 8N1 and SEROUT2 for 7N1 ... using the same output port pin.

    If PORTA.1 = 1 then ; check jumper
    SEROUT PORTB.0, .... ; need 8N1
    else
    SEROUT2 PORTB.0, ... ; need 7N1
    ENDIF

    will that work?

    Also, I do not see why you keep mentioning CCS??? We are taking PBP here
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  10. #10
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    I'll give it a shot this morning. It "should" work.

    Why do I keep mentioning CCS? I only mentioned it once in an effort to show it is possible to do it But upon closer examination, it also only handles it in software only.

    Quote Originally Posted by paul borgmeier View Post
    >>>>two adjacent pins connected together
    another thought - no need for adjacent pins - use SEROUT for 8N1 and SEROUT2 for 7N1 ... using the same output port pin.

    Also, I do not see why you keep mentioning CCS??? We are taking PBP here

  11. #11
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Hi Richard,

    I hope this approach works for you.

    Best of the Day,
    Last edited by paul borgmeier; - 12th February 2008 at 17:50. Reason: grammar
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  12. #12
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    Hi Richard,
    I this approach works for you.
    Best of the Day,
    I ended up using SER2 for the 7,N,1 Stuff then
    using HSER for the 8,N,1 Stuff.

    Check the Dip switch, Configure TXSTA, RCSTA, SPBRG to the values needed or Zero if not needed. This worked great and allowed me to still use the modifiers like in SER2.

    Thanks for the ideas.

    Richard

  13. #13
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Would it be possible to use the pic's hardware USART set at 9600,8,N,1 and receive and transmit data to the 7,N,1 device by simply massaging the bits some.

    When I receive the bytes, I would shift them to the left once and store just the 7 bit value as a byte.

    Before sending the bytes from the array, then make sure the 8th bit is a 1. Wouldn't the 7,N,1 system see this as 7 data bits and two stop bits?

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  3. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  4. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts