Conditional Defines?


Results 1 to 11 of 11

Threaded View

  1. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    When there are no DEFINE's, and an hserout in your program, PBP defaults to 2400 baud in standard USART mode.
    But 2400 baud is too slow at 48Mhz in standard mode.

    When it tries to initialize the USART at the beginning of the program, the value for SPBRG is larger than 255 and gives the "out of range" warning.

    If you use DEFINE's that will work at 48mhz, then the warning will go away and you can manually set the EUSART registers in Enhanced mode whenever needed, like you are doing.

    DEFINE HSER_BAUD 19200

    Or, you can start with enhanced defines that specify SPBRG, then PBP doesn't try to calculate it.

    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 225 ' 2400 Baud @ 48MHz, 0.0%
    SPBRGH = 4
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
    <br>
    Last edited by Darrel Taylor; - 20th June 2010 at 16:53. Reason: Enhanced defines
    DT

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