2 Pics, different baud rates needed


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default 2 Pics, different baud rates needed

    We have
    1 PIC18F2550
    1 PIC18F2423

    Config 2550
    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_ON_2L & _BOR_OFF_2L & _BORV_3_2L & _VREGEN_ON_2L
    @        __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @        __CONFIG    _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    @        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    @        __CONFIG    _CONFIG5L, _CP0_OFF_5L   & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
    @        __CONFIG    _CONFIG5H, _CPB_OFF_5H   & _CPD_OFF_5H 
    @        __CONFIG    _CONFIG6L, _WRT0_OFF_6L  & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
    @        __CONFIG    _CONFIG6H, _WRTB_OFF_6H  & _WRTC_OFF_6H    & _WRTD_OFF_6H 
    @        __CONFIG    _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L  & _EBTR2_OFF_7L   & _EBTR3_OFF_7L 
    @        __CONFIG    _CONFIG7H, _EBTRB_OFF_7H  
    DEFINE OSC 20
    DEFINE CHAR_PACING 1000
    DEFINE HSER_RCSTA 90h 
    DEFINE HSER_TXSTA 20h 
    DEFINE HSER_BAUD 2400
    DEFINE HSER_CLROERR 1
    Config 2423
    Code:
    @        __CONFIG    _CONFIG1H, _OSC_HS_1H    & _FCMEN_OFF_1H   & _IESO_OFF_1H
    @        __CONFIG    _CONFIG2L, _PWRT_ON_2L   & _BOREN_OFF_2L & _BORV_1_2L
    @        __CONFIG    _CONFIG2H, _WDT_OFF_2H   & _WDTPS_1_2H
    @        __CONFIG    _CONFIG3H, _MCLRE_ON_3H  & _LPT1OSC_OFF_3H  & _PBADEN_OFF_3H & _CCP2MX_PORTC_3H
    @        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L     & _XINST_OFF_4L  & _DEBUG_OFF_4L
    @        __CONFIG    _CONFIG5L, _CP0_OFF_5L   & _CP1_OFF_5L
    @        __CONFIG    _CONFIG5H, _CPB_OFF_5H   & _CPD_OFF_5H
    @        __CONFIG    _CONFIG6L, _WRT0_OFF_6L  & _WRT1_OFF_6L
    @        __CONFIG    _CONFIG6H, _WRTB_OFF_6H  & _WRTC_OFF_6H    & _WRTD_OFF_6H 
    @        __CONFIG    _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L    
    @        __CONFIG    _CONFIG7H, _EBTRB_OFF_7H  
    DEFINE OSC 20
    DEFINE CHAR_PACING 1000
    DEFINE DEBUG_REG PORTC
    DEFINE DEBUG_BIT 6
    DEFINE DEBUG_BAUD 19200
    DEFINE DEBUG_PACING 100
    DEFINE DEBUGIN_REG PORTC
    DEFINE DEBUGIN_BIT 7
    DEFINE SER2_BITS 8
    DEFINE HSER_RCSTA 90h 
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 6000
    DEFINE HSER_CLROERR 1
    Code Example:
    Code:
    preprogramloop:
    IF OtherPICconnected THEN ' check a I/O-pin
        'PAUSE 50
        HSERIN 1000, preprogramloop, [WAIT("#"), STR SeriellBuffer\2]
        IF SeriellBuffer[0] = "X" AND SeriellBuffer[1] = "X" THEN 
            HSEROUT ["@OK"]
            GOTO Docked
        ENDIF
        GOTO preprogramloop
    ENDIF
    We measured the 2550 + 2423 TX lines with an oscilloscope until we found a HSER_BAUD rate that matched and we got no problem communicating between those two PICs.

    Does it make any sense that those two HSER_BAUD settings differ?

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

    Default

    What do you have for an external OSC on the 2550?
    I doubt it is running at 20MHz. Maybe 48?
    Dave
    Always wear safety glasses while programming.

  3. #3

    Default

    No, it really definitly is running on 20 Mhz,

    Fuse PLLDIV_5_1L provides internal 4MHz which is used to to drive the 96Mhz internal PLL which gets divided to 48Mhz for USB via _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L. Fuse _FOSC_HSPLL_HS_1H should select the right frequency for the MCU promary clock.
    DS39632E-page 31 & schema on DS39632E-page 24

    Have no PBP at home, only able to access the source. If you have access to the PBP libs and lookup the PBP config fuses, it should show that a 20 MHz OSC could work.

    USB communication is no problem, the 2400 baud on 2550 is seen on oscilloscope IIRC. (now at home - at friday night or saturday able to clock it again).

    Thanks for the fast reply.

  4. #4

    Thumbs up Solved, wrong fuse/OSC

    Quote Originally Posted by peter_wiersig View Post
    We have
    1 PIC18F2550
    1 PIC18F2423

    Config 2550
    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
    ...
    DEFINE OSC 20
    We measured the 2550 + 2423 TX lines with an oscilloscope until we found a HSER_BAUD rate that matched and we got no problem communicating between those two PICs.

    Does it make any sense that those two HSER_BAUD settings differ?
    Those fuses let the 2550 run at 48 MHz, we coded a sample program and measured again with our oscilloscope

    Code:
    DebugLoop:
    TOGGLE PORTC.1
    PAUSE 100
    GOTO DebugLoop
    Which showed a ~40 ms pulse on the 2550 and a 100 ms pulse on the 2423, from there it was back to the data sheets and we found our error.

    config 2550
    Code:
    @        __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @        __CONFIG    _CONFIG1H, _FOSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    DEFINE OSC 20

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  3. help about connecting 2 PICs
    By micro in forum mel PIC BASIC
    Replies: 1
    Last Post: - 1st January 2006, 13:52
  4. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 02:17
  5. 2 PIC's 1LCD
    By puma in forum General
    Replies: 2
    Last Post: - 3rd August 2004, 17:58

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