Redefinition of CON bmode during runtime


Closed Thread
Results 1 to 5 of 5
  1. #1
    Pedro Pinto's Avatar
    Pedro Pinto Guest

    Question Redefinition of CON bmode during runtime

    Hello

    I need only in the start of my program a 2400 baudrate, later im programm during runtime i need to change the baurate to 9600, but become error by the compiler "Redefinition of CON bmode"
    How can i do that?

    Thanks in advance

    Best regards

    Pedro

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You can change your baudrate any time during runtime by issuing the command

    SPBRG = x,

    where "x" is a number you will find in your datasheet and
    is based on your oscillator, and the BRGH and BRG16 settings.

    After changing the baud rate, pause at least two byte-times before you
    attempt to use the serial port.
    Charles Linquist

  3. #3
    Pedro Pinto's Avatar
    Pedro Pinto Guest


    Did you find this post helpful? Yes | No

    Default

    Thank You Charles

    Regards

    Pedro

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Pedro,
    What Charles said is proper for HSERIN and HSEROUT, I have a little program I use to test serial LCD units using SEROUT and it works for several baudrates, here is a sample of the code.
    Code:
    SEROUT PortB.7,N2400,[254,128,"2400 baud line 1~"]'inverted
    pause 100
    serout PortB.6,N9600,[254,128,"9600 baud line 1~"] '128 so as not to add space
    pause 100
    SEROUT PortB.5,T2400,[254,128,"2400 baud line 1~"]'true
    pause 100
    serout PortB.4,T9600,[254,128,"9600 baud line 1~"] '128 so as not to add space
    pause 1000
    each output having a different baudrate.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Pedro Pinto's Avatar
    Pedro Pinto Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Joe

    What Charles say is what i need

    i have this for soft usart
    bmode con 16780' serin2' 16780 = 2400 true
    '
    'and set with this the hardware usart for 10466 baudrate, i have not tested, next week
    'can i test, and hope that this work
    '
    ' Set receive register to receiver enabled
    DEFINE HSER2_RCSTA 90h
    ' Set baud rate
    ' Set SPBRG directly (normally set by HSER_BAUD)
    DEFINE HSER2_SPBRG 23


    Regards
    Pedro

Similar Threads

  1. Sony SIRC IR Issue
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th August 2015, 09:10
  2. PIC 18F4550 and MCP23017
    By DaveC3 in forum Code Examples
    Replies: 12
    Last Post: - 4th December 2010, 15:01
  3. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 20:52
  4. example code for DS1337
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 8th December 2009, 22:16
  5. Parallax GPS Receiver
    By emavil in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th February 2009, 10:35

Members who have read this thread : 1

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