PIC18F4550 to 18F4553 Comm Issue?


Closed Thread
Results 1 to 19 of 19
  1. #1
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44

    Question PIC18F4550 to 18F4553 Comm Issue?

    I'm having trouble figuring this one out. I have code that works on my circuit board with a 4550, I changed to a 4553 so I could use a 12bit A/D. I moved the code that works with the 4550 to the 4553. Everything is working but I can't get the EUSART communication to work. It seems like it's not getting the interrupt, to trouble shoot I put an LCD message in the receive interrupt routine with a pause, the message is never displayed. I use DT interrupts for timers/clock and that part works, the RX_INT is in the same section, so I believe that should be OK. So my thought is there may be some difference in the DEFINES for the serial port baud rates etc. Trouble is the data sheet for the 4553 doesn't have a section for the EUSART so I can't put the data sheets side x side to compare. The data sheet for the 4553 is 46 pages, 4550 data sheet is 438 pages.

    Tomorrow I plan to solder some wires to the board so I can connect the serial to my PC to see if I can send/receive anything to my computer.

    For now I guess I have two questions, where is the complete data sheet for the 18F4553, and do you know if the serial defines I included would work on the 4553? These work just fine on the 18F4550.


    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive   
    DEFINE HSER_TXSTA 164 ' Enable brg, Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 10 ' 115200 Baud @ 20MHz, -1.36%  pg 245 spbrg vals
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    Thanks

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    http://www.microchip.com/wwwproducts/en/PIC18F4553

    At quick glance, they both use the same pins for EUSART, so that's a good thing.

    Check out this funky register on the 4553: DEVID1. EDIT: never mind, The Device ID registers are “read-only” registers

    Don't look for more pages in a 4553 datasheet, there are none:
    This document is supplemented by the “PIC18F2455/2550/4455/4550 Data Sheet”
    It is compatible with the 4550, so you're missing something very small if you already have it working between two 4550.

    Hmm, very dumb question: have you changed the model when you compile?

    Robert
    Last edited by Demon; - 13th April 2016 at 02:28.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    page 7 of the "46 page abridged version"

    Note:
    This data sheet documents only the
    devices’ features and specifications that are
    in addition to the features and specifications
    of the PIC18F2455/2550/4455/4550
    devices. For information on the features
    and specifications shared by
    the PIC18F2458/2553/4458/4553 and
    PIC18F2455/2550/4455/4550 devices,
    see
    the PIC18F2455/2550/4455/4550

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    to trouble shoot I put an LCD message in the receive interrupt routine with a pause, the message is never displayed.
    PAUSE within an interrupt aren't a good idea.

    Set a flag to 0,
    Set it within your routine,
    Then check it within your main program.

    What if you copy your programs for both pics down to bare EUSART code and try to get them talking?

    Are you sure it worked right before with two 4550?

    Uh, did you put the 4553 in backwards?

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    Thanks for the responses, I can stop looking for the rest of the data sheet. I was too busy looking for fine print I overlooked the highlighted section that says it's the same as the 4550.

    I did get wires connected between the 4553 board and my PC. I put an HSEROUT in my main routine to send a message out once per second. All I get is qbert "«Š¥h” ejg«üa©Š¥Gh” ", I can move the wires to the 4550 board and the message displays fine.

    The 4553 isn't in backward (I've done that before, so it's the first thing I check now!). I also have an LCD and LED's that are driven from the 4553, those all work fine.

    I'll start a new program for the 4553 and just put in the bare EUSART as suggested. Hopefully I can find my error.

    Let me know if you have any other idea's.
    Thanks

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    If your LED and LCD work fine on the 4553, then that PIC is working fine.

    If your 4550 can talk to another 4550, then that PIC is working fine.

    Are you using the right TX/RX pins on the 4553?

    There's really not a lot of possibilities here. The 4553 is EUSART compatible with a 4550. It is basically a 4550 with a different name.

    Do you use different wires?

    Do you do a simple drop-in substitution for the 4553, or do you have a separate breadboard circuit set up?

    What about a heartbeat LED?
    Main:
    LEDout = 0
    PAUSE 500
    LEDout = 1
    PAUSE 500
    GOTO Main
    END
    If you're using a separate circuit for the 4553, does this do a 1 second pulse?
    (I was thinking of a timing issue, LED and LCD might work fine, but EUSART would be more finicky)

    Just trying to eliminate all possibilities I can come up with.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    No expert, but these are things I look at when having issues with serial coms.

    Timing: The crystal and OSC value need to be right. On one project the code ran and the program functioned, but when communications was tested I got garbage streamed out to the PC. I then changed the xtal from 12mhz to a 10mhz and it worked fine.

    Try something like this with a 10mhz crystal fitted

    Code:
    DEFINE  OSC 20                          ' 18F4520, 10mhz crystal
    ADCON1 = $0F
    clear 
    
     ;----[UART Settings]------------------------------------------------------------
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 8   ' 9600 Baud @ SPBRGH = 2
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    
    
    RCSTA = $90   ' Enable serial port & continuous receive
    TXSTA = $24   ' Enable transmit, BRGH = 1
    SPBRG = 8     ' 9600 Baud @ -0.03%
    SPBRGH = 2
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
    
    
    RCIF                VAR PIR1.5                    ' USART receive flag
    Char                VAR BYTE                      ' USART byte received
    GIE                 VAR INTCON.7
    Then try your HSEROUT routine

    There was a useful calculator that worked out the settings based on the timings which might help http://www.picbasic.co.uk/forum/showthread.php?t=4994

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    Another option is to use the built-in oscillator. That's what I used here on the slave 18F44K22 and ran at 115,200:

    http://www.picbasic.co.uk/forum/show...524#post130524

    Master 18F4550 at 48 MHz using external 20MHz oscillator
    Slave 18F44K22 at 64 MHz using internal oscillator

    If I read the datasheet right, the internal oscillator is limitted at 8 MHz on the 4550. Maybe that's enough for your needs.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    I see no reason why you couldn't use an external 20 MHz crystal on the 4550 and 4553, and run them at 48 MHz.

    Try with these settings, I know these worked.

    Code:
    ' 184550 external oscillator 20MHz
    ...
    DEFINE OSC 48
    ...
    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 25                ' 115200 Baud @ 48MHz, 0,16%
    SPBRGH = 0
    BAUDCON.3 = 1                       ' Enable 16 bit baudrate generator
    I used 22pF ceramic caps on the crystal.

    Like these round brown ones:
    http://www.capacitorguide.com/ceramic-capacitor/

    Also, notice this has a low error percentage despite the higher rate, only 0.16% compared to your 1.36% (I'm assuming negative is irrelevant on this value, I could be wrong).

    One last thing, 48 MHz on the 4550 would let you use USB later if that's a requirement.

    Robert
    Last edited by Demon; - 14th April 2016 at 00:03.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  10. #10
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    Still no luck, the data I receive on my PC is garbled from the 4553, I've tried dozens of baud rates and settings. I plugged the com back into a board with a 4550 and the data from it is fine. Both are running external 20 MHz crystals, boards and design is similar. I copied the code and board design from the 4550 and just changed what I needed to for the new design. I tried the suggested settings from here and had the same results. I got an error when I changed the OSC to 48.

    Also, my title may be confusing. What I'm doing is upgrading from a 4550 to 4553 on a board design/upgrade, the EUSART comm isn't working correct on the 4553 yet.

    Tomorrow I'll take one of the boards, de-solder the 4553 and put the 4550 on it just so I can completely double check for an issue with the board.

    As a little backstory the boards take external values and send the information via a cell phone to a remote server. This is working fine on boards with the 4550, but we wanted the 12bit AD for the next phase.

    The cell phone needs a baud of 115200.

    I'm not sure if something that I have configured might load defaults a little different from the 4550 to 4553?

    Below is the current DEFINES and CONFIGS, after this I set some variables and have a 1 second loop the sends HSEROUT ["Hello",13,10], toggles an LED and updates a seconds counter on the LCD. Data received by PC acts like the baud rate its bad, LED blink and LCD updates fine.

    Let me know if you think of anything that may help.
    Thanks

    Code:
    Define OSC 20
    
       
    DEFINE LCD_DREG          PORTD  'Port used for LCD Data
    DEFINE LCD_DBIT          0      'First Pin connected to LCD DB4
    DEFINE LCD_RSREG         PORTB 'Port used for LCD RS line
    DEFINE LCD_RSBIT         2     'Pin used for LCD RS line
    
    DEFINE LCD_EREG          PORTA 'Port used for LCD E Reg
    DEFINE LCD_EBIT          4     'Pin used for LCD E line
    DEFINE LCD_BITS          4     'Four bit comm mode
    DEFINE LCD_LINES         2     '2 Line LCD
    DEFINE LCD_COMMANDUS     900    'Delay between sending LCD commands
    DEFINE LCD_DATAUS        75      'Delay time between data sent
      
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h  'External Clock, Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 10 ' 115200 Baud @ 20MHz, -1.36%   
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically  
     BAUDCON.3 = 0        ' BRG16 = 0      
     
      TRISC.7=1
      TRISC.6=1      
            
            
      'Re-Configure default values from the PBP 18F4553.inc and MCSP/MPASM .inc
            
       ' Ext XTAL setting
         '_PLLDIV_5_1L  20Mhz HS / 5 for PLL 4 Mhz
        '_CPUDIV_OSC3_PLL4_1L  24Mhz CPU for USB 1 speeds, PLL 96Mhz/4 =24Mhz
        'HS oscillator, PLL enabled (HSPLL)  
           '                   
        'asm
        #CONFIG
              __CONFIG  _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC3_PLL4_1L & _USBDIV_2_1L
              __CONFIG  _CONFIG1H, _FOSC_HSPLL_HS_1H
        #ENDCONFIG   
        'endasm
        
        INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
        INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
        INCLUDE "Elapsed_INT-18.bas"  ; Elapsed Timer Routines
        ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
                INT_Handler    TMR1_INT,  _ClockCount,   PBP,  yes
                INT_Handler    RX_INT,     _Check_Command, PBP, yes 
            endm
            INT_CREATE               ; Creates the interrupt processor
        ENDASM
    
       
    @ INT_ENABLE    TMR1_INT     
    @ INT_ENABLE    RX_INT

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    #CONFIG
    __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC3_PLL4_1L & _USBDIV_2_1L
    __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
    #ENDCONFIG
    with a 20 MHz xtal would result in a fosc of 24 MHz


    Define OSC 24

    DEFINE HSER_SPBRG 12


  12. #12
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    Ok, so now it works, but I'm more confused...Define OSC 24 causes and error (Frequency not defined), but I changed HSER_SPBRG to 12 any way, and everything is working fine.
    So, why? Apparently my understanding of figuring out the settings is incorrect, although I must have understood it at one point

    Can anyone explain this?
    Thanks

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    for pbp3 Define OSC 24 is a valid define
    from the book
    2.3.1 DEFINE OSC
    There are a limited number of valid numbers that can be used: 3 (3.58MHz), 4, 8,
    10, 12, 16, 20, 24, 25, 32, 33, 40, 48, 64. These are the only frequencies for which
    PBP is able to accurately calibrate its timing. If you use a system clock that runs at
    a frequency that isn't listed here, your timing will be scaled when the program
    executes.
    24 is in the list

    osc setting
    Code:
                                                       USBDIV_2_1L
                                        / =========== 96/2 = 48 ----   usb
    20 mhz  /5  = 4 :-  pll =  96mhz  :
          PLLDIV_5_1L                   \============  96/4 = 24 ---   fosc
                                                       CPUDIV_OSC3_PLL4_1L

  14. #14
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    Code:
    ' 184550 external oscillator 20MHz
    ...
    DEFINE OSC 48
    ...
    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 25                ' 115200 Baud @ 48MHz, 0,16%
    SPBRGH = 0
    BAUDCON.3 = 1                       ' Enable 16 bit baudrate generator
    I should have included the CONFIGs though, they are still in PBP v2.60c format but the settings are easily convertible:
    Code:
    @   __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    _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_1_2L & _VREGEN_ON_2L
    @   __CONFIG    _CONFIG2H, _WDT_OFF_2H
    @   __CONFIG    _CONFIG3H, _CCP2MX_OFF_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    @   __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    But Richard is a senior member for a reason.

    Robert
    Last edited by Demon; - 15th April 2016 at 01:16.

  15. #15
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Smile Re: PIC18F4550 to 18F4553 Comm Issue?

    Thought I give an update. I did get the communication working at 115200 using the 24 Mhz clock setting. But then my DT interrupts timer was running 20 % fast (24/20). If enable the HSPLL it seems PLL becomes my primary clock, my understanding is the FOSC3:FOSC0 and OSCCON would select the primary oscillator if set? So I guess I'm not reading the data sheet correct or just not getting it set correct.

    To keep DT timer correct I changed to _FOSC_HS_1H and _CPUDIV_OSC1_PLL2_1L to disable the PLL. DT interrupts are timing correct again.

    Then I changed communication settings to
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h  'External Clock, Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 10 ' 115200 Baud @ 20MHz, -1.36%  
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically  
    BAUDCON.3 = 0        ' BRG16 = 0
    The OSC define is set to 20. Communication and timing is all working correct again.

    As a side note, since I couldn't get Define OSC 24 to work I tried frequencies from the list
    2.3.1 DEFINE OSC
    There are a limited number of valid numbers that can be used: 3 (3.58MHz), 4, 8,
    10, 12, 16, 20, 24, 25, 32, 33, 40, 48, 64
    The frequencies that didn't cause an error are; 4, 8, 12, 16 and 20. The others give me an error of frequency not defined or previously used. Not sure what's causing that?

    I'm still not sure why the Clock/frequency/PLL configuration settings on the 4550 work, but on the 4553 I needed to change _FOSC_HS_1H and _CPUDIV_OSC1_PLL2_1L to keep DT clock running at 20Mhz and Communications clocking at 20 Mhz? The circuit board setup is the same, crystal is the same, same DT interrupts loading etc. The thing that isn't the same is the 4550 is programmed with a boot loader, and the 4553 I'm programming with PicKit 3. I wonder if the boot loader was changing some of the configurations on the 4550 in the background that I wasn't setting?

    Anyway, I'm up and running, thanks for the help! Let me know if you have any more insight that would help me get unconfused.
    Thanks
    Shane

  16. #16
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    I wouldn't be surprised if either the bootloader or the Pickit 3 was overriding your config fuses.

    But I've never used either.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  17. #17
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    The thing that isn't the same is the 4550 is programmed with a boot loader
    You probably should have mentioned that in post #1.

    Most bootloaders won't allow you to reprogram the CONFIG section (since that will likely break the bootloader), while the PICkit3 will load whatever you've set in the hex file.

  18. #18
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Smile Re: PIC18F4550 to 18F4553 Comm Issue?

    I defiantly would have mentioned Pickit vs bootloader if I thought that would have anything to do it. I thought they would program what ever I had configured. Sounds like that may not be how the boot loader works though? Good to know.

    Thanks

  19. #19
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 to 18F4553 Comm Issue?

    It depends on the bootloader you're using... some will, some won't, so it's worth checking.

    It's usually a good idea NOT to allow the config to be reprogrammed. For example, if you goof up/change the osc setting you can easily turn your board into a brick.

Similar Threads

  1. RS232 comm
    By longdw in forum Serial
    Replies: 9
    Last Post: - 15th September 2009, 03:13
  2. trade 18F4553-I/P (really want 16c717/JW)
    By nomad in forum Adverts
    Replies: 2
    Last Post: - 1st November 2008, 22:49
  3. Code Issue - select case or 'if' issue - not sure why
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th October 2007, 08:52
  4. serial comm problem
    By win_832001 in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 29th June 2006, 13:57
  5. Serial comm Problems
    By Fossil in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th January 2004, 02:29

Members who have read this thread : 3

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