HSERIN HSEROUT - Baud rate help


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    It looks like your transmitter is set to 2400, but your receiver is set for 9600 baud.

    check out:
    Code:
    DEFINE HSER_TXSTA 20h       'Set receive register to TX en
    define HSER_SPBRG 25
    DEFINE HSER_SPBRGH 1
    I like using PicMultiCalc. It can be found here: http://www.picbasic.co.uk/forum/cont....-PICMultiCalc

    Then I can just paste it into my code. Here is one for 2400 baud, and one for 9600 baud.
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 25  ' 2400 Baud @ 4MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 25  ' 9600 Baud @ 4MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    http://www.scalerobotics.com

  2. #2
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Thanks - it works a treat now! Really appreciate your help. That Mister E is a clever fello

  3. #3
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default Sorry guys I'm back

    The PIC16f722 was doing funny things, in desperation I threw it away and went back to the trusty 16F88 however this is not working for me either.

    The PicKit 3 I bought was driving me mad also, so it's back to the ETT programmer and PicKit 2 software.

    It compiles and assembles ok, but it will not program. The programmer says "Verification of Configuration Failed" It programs fine if I get rid of anything to do with HSEROUT the defines and the command.

    But the instant I bring in an HSEROUT command it will fail.

    Here's the code:

    Code:
    @ __config _CONFIG1, _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF & _MCLR_OFF
    'pic16f88
    ADCON0 = %00000000      'ADC Disabled
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 25  ' 9600 Baud @ 4MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
                       
    ANSEL = 0 			'ALL DIGITAL
    CMCON = 7 			'COMPARATORS OFF
    INTCON = 0 			'Disable interrupts
    TRISB = %00001111 		'SET PORTB RB2(RX) as input, others to OUTPUT
    TRISA = %00000000 		'SET PORTA AS OUTPUTS
    
    porta = 63
    PAUSE 1000
    
    'LeftBtn Var PORTB.1
    'RiteBtn Var PORTB.3
    'StopBtn VAR PORTB.0
    'RadioEn var PortB.4
    
    B0      VAR BYTE
    B1      var byte
    B2      var byte
    TXdata  var byte
    Direction var byte
    LEDPtrn var byte
    WakeVar var byte
    MtrPwr  var bit
    
    pause 1000
    clear
    
    porta = 0
    
    start:
    txdata = 100
    hserout [txdata]
    pause 1000
    goto start
    I'm going completely nuts over this and I think I'm about to get fired for being so useless. Please help

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I do not know what is going on with the HSEROUT but you may want to correct something else. Who knows, maybe it will solve the other.

    RA5 can only be an input. You have.
    TRISA = %00000000 'SET PORTA AS OUTPUTS

    Then this
    porta = 63 = 00111111
    Dave
    Always wear safety glasses while programming.

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    On the 18 pin device it appears that RA7 is also input only !

    http://ww1.microchip.com/downloads/e...doc/30487c.pdf

    Also, and whilst no expert on your settings you have
    Code:
    TRISB = %00001111 		'SET PORTB RB2(RX) as input, others to OUTPUT
    TRISA = %00000000 		'SET PORTA AS OUTPUTS
    
    porta = 63
    PAUSE 1000
    
    'LeftBtn Var PORTB.1
    'RiteBtn Var PORTB.3
    'StopBtn VAR PORTB.0
    'RadioEn var PortB.4
    you have set PORTB as output apart from RB2 but appear to have buttons which are normally inputs ( taking pin high or low) on RB1, RB3, RB0 and RB4 ?, but appear to have set it correctly with TRISB = %00001111
    Last edited by malc-c; - 15th September 2010 at 08:13.

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