Hserout sends wrong values


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2016
    Posts
    33

    Default Hserout sends wrong values

    Hello again,
    I have a working code for sending a byte using PIC18F24J50 but the same code doesn't send the correct values in PIC18F2450. I send $05 and receive 252 instead.

    Here is my code:
    Code:
    DEFINE LOADER_USED 1
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_BAUD 115200
    DEFINE HSER_SPBRG 12 
    DEFINE HSER_CLOERR 1
    DEFINE OSC 24
    
    ADCON0 = 000000
    ADCON1 = 001011
    ADCON2 = 110101
    
    TRISC.0 = 0
    TRISC.1 = 1
    TRISC.6 = 0
    TRISC.7 = 1
    
    
    tx1 VAR PORTC.6
    rx1 VAR PORTC.7
       
    LED VAR PORTC.0  
    Pause 1000
    
    mainloop:
    
       high LED
       Pause 1000 
    
      Hserout [$05] 
       Pause 100
       
        low LED
       Pause 1000 
    
       Goto mainloop
    Any ideas? Thanks!

  2. #2
    Join Date
    May 2016
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Re: Hserout sends wrong values

    I also get 50 when I set HSER_TXSTA to 20h in low speed.

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


    Did you find this post helpful? Yes | No

    Default Re: Hserout sends wrong values

    Are both chips running at the same speed?
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Hserout sends wrong values

    config is ?
    Warning I'm not a teacher

  5. #5
    Join Date
    May 2016
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Re: Hserout sends wrong values

    I am using standard config in P18F2450.INC file.

    Code:
            NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F2450, r = dec, w = -311, w = -230, f = inhx32
            INCLUDE "P18F2450.INC"    ; MPASM  Header
            __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H,_PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
            __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_BB1K_4L & _XINST_OFF_4L
            NOLIST
        endif
            LIST
    EEPROM_START    EQU    0F00000h
    BLOCK_SIZE    EQU    16

    I basically trying to read the result using an arduino.


    Here are sample of values I sent and values I get when I use Putty/Serial software :

    Code:
    Sent Received 
    0     1
    1     2
    2    12
    3    14
    4    48
    5    50
    6    60
    7    62
    8    192
    9    194
    10    204

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Hserout sends wrong values

    xtal used is ?
    Warning I'm not a teacher

  7. #7
    Join Date
    May 2016
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Re: Hserout sends wrong values

    Quote Originally Posted by richard View Post
    xtal used is ?
    It's a 24 mhz xtal.

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Hserout sends wrong values

    the default config is for a 20mhz xtal which gives a fosc of 48mhz

    to use a 24 MHz xtal change plldiv to 6 for a 48mhz fosc or turn the pll off .
    24 mhz into the pll @ plldiv5 is out of device specs.
    with pll off and cpudiv=1 fosc=24mhz fo a 24mhz xtal.
    Warning I'm not a teacher

Similar Threads

  1. Why does this PBP statement post the wrong time values?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2011, 03:10
  2. Replies: 7
    Last Post: - 22nd February 2011, 20:20
  3. WRITECODE stores wrong 14-bit word values in FlashMEM
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 26th June 2009, 04:35
  4. PIC16F877 sends/receives data to/from a PC
    By ovidiu in forum Serial
    Replies: 1
    Last Post: - 2nd December 2006, 14:09
  5. Wrong values with COSINE!
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 8th May 2006, 16:59

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