+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: PIC 18F8722 Hserin2/Hserout2 problems

  1. #1

    Default PIC 18F8722 Hserin2/Hserout2 problems

    Hi everyone.

    I am having problems sending and receiving data through the second serial port of the 18F8722 PIC.

    My Fuses and declares are as follows:

    Code:
    XTAL 10
            
    'Fuse Configuration    
    CONFIG_START
        OSC = HSPLL    ;High Speed with PLL
        FCMEN = OFF    ;Fail-Safe Clock Monitor disabled
        IESO = OFF    ;Two-Speed Start-up disabled
        PWRT = On    ;PWRT disabled
        BOREN = SBORDIS    ;Brown-out Reset enabled in hardware only (SBOREN is disabled)
        BORV = 0    ;Minimum setting
        WDT = Off    ;WDT enabled
        WDTPS = 1024    ;1:1,024
        MODE = MC    ;Microcontroller mode
        ADDRBW = ADDR16BIT    ;20-bit Address Bus
        DATABW = DATA16BIT    ;16-bit External Bus mode
        Wait = OFF    ;Wait selections are unavailable for table reads and table writes
        CCP2MX = PORTC    ;ECCP2 input/output is multiplexed with RC1
        ECCPMX = PORTE    ;ECCP1/3 (P1B/P1C/P3B/P3C) are multiplexed onto RE6, RE5, RE4 and RE3 respectively
        LPT1OSC = OFF    ;Timer1 configured for higher power operation
        MCLRE = OFF    ;RG5 input pin enabled; MCLR disabled
        STVREN = OFF    ;Stack full/underflow will not cause Reset
        LVP = Off    ;Single-Supply ICSP enabled
        BBSIZ = BB2K    ;1K word (2 Kbytes) Boot Block size
        XINST = OFF    ;Instruction set extension and Indexed Addressing mode enabled
        Debug = OFF    ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
        CP0 = OFF    ;Block 0 (000800, 001000 or 002000-003FFFh) not code-protected
        CP1 = OFF    ;Block 1 (004000-007FFFh) not code-protected
        CP2 = OFF    ;Block 2 (008000-00BFFFh) not code-protected
        CP3 = OFF    ;Block 3 (00C000-00FFFFh) not code-protected
        CP4 = OFF    ;Block 4 (010000-013FFFh) not code-protected
        CP5 = OFF    ;Block 5 (014000-017FFFh) not code-protected
        CP6 = OFF    ;Block 6 (01BFFF-018000h) not code-protected
        CP7 = OFF    ;Block 7 (01C000-01FFFFh) not code-protected
        CPB = OFF    ;Boot Block (000000-0007FFh) not code-protected
        CPD = OFF    ;Data EEPROM not code-protected
        WRT0 = OFF    ;Block 0 (000800, 001000 or 002000-003FFFh) not write-protected
        WRT1 = OFF    ;Block 1 (004000-007FFFh) not write-protected
        WRT2 = OFF    ;Block 2 (008000-00BFFFh) not write-protected
        WRT3 = OFF    ;Block 3 (00C000-00FFFFh) not write-protected
        WRT4 = OFF    ;Block 4 (010000-013FFFh) not write-protected
        WRT5 = OFF    ;Block 5 (014000-017FFFh) not write-protected
        WRT6 = OFF    ;Block 6 (01BFFF-018000h) not write-protected
        WRT7 = OFF    ;Block 7 (01C000-01FFFFh) not write-protected
        WRTC = OFF    ;Configuration registers (300000-3000FFh) not write-protected
        WRTB = OFF    ;Boot Block (000000-007FFF, 000FFF or 001FFFh) not write-protected
        WRTD = OFF    ;Data EEPROM not write-protected
        EBTR0 = OFF    ;Block 0 (000800, 001000 or 002000-003FFFh) not protected from table reads executed in other blocks
        EBTR1 = OFF    ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
        EBTR2 = OFF    ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
        EBTR3 = OFF    ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
        EBTR4 = OFF    ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
        EBTR5 = OFF    ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
        EBTR6 = OFF    ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
        EBTR7 = OFF    ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
        EBTRB = OFF    ;Boot Block (000000-007FFF, 000FFF or 001FFFh) not protected from table reads executed in other blocks
    CONFIG_END            
                
                PLL_REQ = On                      'PLL Devider by 4 so we run at 40MHz                    
                
                INTCON2.7 = 1                     'Disable Pullup Resistors on Port B
                ALL_DIGITAL = On                  'Set All pins to Digital       
                
                'Setup Hardware Serial 1 
                HSERIAL_BAUD = 38400              'Set baud rate to 38400
                HSERIAL_RCSTA = %10010000         'Enable serial port and continuous receive
                HSERIAL_TXSTA = $24               'Enable transmit and asynchronous mode 
                HSERIAL_CLEAR = On                  'Enable Error clearing on received characters
                
                'Setup Hardware Serial 2
                HSERIAL2_BAUD = 38400              'Set baud rate to 38400
                HSERIAL2_RCSTA = %10010000        'Enable serial port and continuous receive
                HSERIAL2_TXSTA = $24              'Enable transmit and asynchronous mode 
                HSERIAL2_CLEAR = On                  'Enable Error clearing on received characters
                
                'General Switches
                ADCON0.0 = 0                       'Disable A/D converter
                MEMCON.7 = 1                       'Disable External Memory Bus controller on PORT D
                CMCON.0 = 1                        'Comparators OFF
                CMCON.1 = 1
                CMCON.2 = 1
    For some reason the declares:

    Code:
    HSERIAL2_BAUD = 38400  
    HSERIAL2_CLEAR = On
    are not being highlighted as the rest of the declares but it compiles fine.

    I have managed to go around the serial send/receive problem by doing the following for the receive:

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




    Code:
                RCSTA2 = %10010000        'Enable serial port and continuous receive
                TXSTA2 = $24              'Enable transmit and asynchronous mode               
                RCSTA2.7 = 1    'Enable Serial port
                RCSTA2.4 = 0    'Continuous Receive Disabled
                RCSTA2.4 = 1    'Continuous Receive Enabled
                HSerIn2 [Wait("D"),SW_Main_Val[9],SW_Main_Val[10],SW_Main_Val[11]]
                RCSTA2.7 = 0    'Disable Serial port

    And for the transmit:

    Code:
    'Our Serial Configs
                        RCSTA2 = %10010000        'Enable serial port and continuous receive
                        TXSTA2 = $24              'Enable transmit and asynchronous mode
                        HSerOut2 ["C","M",UI_Cur_Selection,UI_EEAddress.LowByte,UI_EEAddress.HighByte,1,3,"sss00"] 'Send the command
    The problem is that this is unstable and sometimes works and other times i have to reset the IC a couple of times to make it work.

    My question is: Is there some bug in the compiler and i get this problem? Also why doesn't the command just work on it's own as the First serial port does and i have to manually reset the port each time?

    It doesn't matter if i use HSerout or Hrsout, the problem is the same.

    I am using the compiler version: 3.5.2.7

    Any help about this would be appreciated.


  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    Any info? I could really use the help on this.

  4. #3


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    Can Someone Help me with this?

  5. #4
    Licensed User SmallFry's Avatar
    Join Date
    Mar 2006
    Location
    Hampshire UK
    Posts
    367


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    I have used two serial ports on an 18F46K22 and they worked fine but I seem to remember that I needed to tris the ports, ie rx input, tx output for it to work.

  6. #5


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    My problem is not that the serial doesn't work. It works but it sends and receives data as if it is shifted every single cycle. The PIC i have is 18F8722

  7. #6


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    I've used this chip and it's HSER ports without problem in the past. Have you tried paring your program down to barest essentials on one port at a time, and a slower baud rate, to see if you can get it working reliably. Then add the other port, increase the baud rate etc.?
    J. Mark Wolf
    Pinckney, Michigan
    Rotorway 162F N1955Z
    Website:www.ucosm.com/helicopter

  8. #7


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    I have tried everything.

    Perhaps it would be helpful if you could post your fuses as well as Serial configurations for the Second port from your Past code which worked?

  9. #8


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    Below is what worked for me:

    Sorry, the "wrap code tags" doesn't work for me anymore. It wouldn't let me select the entirety of the pasted text, and it screws up the formatting.
    '
    Device 18F8722' Produce code for a 18F452 PIC micro device
    Xtal 20 ' PRIOR TO PLL
    '
    Config_Start
    OSC = HSPLL ' HS Oscillator
    FCMEN = OFF ' Failsafe Clock Monitor Disabled
    IESO = OFF ' Int/Ext Oscillator Switch Over Disabled
    PWRT = On ' Power Up Timer Enabled
    BOREN = OFF ' Brownout Reset Disabled
    BORV = 0 ' Brownout Reset Voltage 4.6V
    WDT = OFF ' Watchdog Timer Disabled
    WDTPS = 1 ' Watchdog Postscaler: 1:1
    MCLRE = On ' MCLR Enabled
    LPT1OSC = OFF ' T1 Oscillator Disabled
    CCP2MX = PORTC' CCP2 Mux Muxed with RC1
    STVREN = On ' Stack Overflow Reset Enabled
    LVP = OFF ' Low Voltage ICSP Disabled
    XINST = OFF ' XINST Disabled
    Debug = OFF ' Background Debugger Disabled
    CP0 = OFF ' Code Protection Block 0 Disabled
    CP1 = OFF ' Code Protection Block 1 Disabled
    CP2 = OFF ' Code Protection Block 2 Disabled
    CP3 = OFF ' Code Protection Block 3 Disabled
    CPB = OFF ' Boot Block Code Protection Disabled
    CPD = OFF ' Data EEPROM Code Protection Disabled
    WRT0 = OFF ' Write Protection Block 0 Disabled
    WRT1 = OFF ' Write Protection Block 1Disabled
    WRT2 = OFF ' Write Protection Block 2 Disabled
    WRT3 = OFF ' Write Protection Block 3 Disabled
    WRTB = OFF ' Boot Block Write Protection Disabled
    WRTC = OFF ' Configuration Register Write Protection Disabled
    WRTD = OFF ' Data EEPROM Write Protection Disabled
    EBTR0 = OFF ' Table Read Protection Block 0 Disabled
    EBTR1 = OFF ' Table Read Protection Block 1 Disabled
    EBTR2 = OFF ' Table Read Protection Block 2 Disabled
    EBTR3 = OFF ' Table Read Protection Block 3 Disabled
    EBTRB = OFF ' Boot Block Table Read Protection Disabled
    Config_End
    '
    Declare Warnings On' Enable complier warning message
    Declare Reminders On' Enable complier reminder messages
    '
    '************************************************* *****************************
    '
    TRISA = %00111111 'set A/D pins as inputs
    TRISB = %00111011 '
    TRISC = %10010000 '
    TRISD = %00100000 '
    TRISE = %00000000 '
    TRISF = %11111111 '
    TRISG = %00000100 '
    TRISH = %00010000 '
    TRISJ = %00001111 '
    '
    INTCON = %00000000 'config INTERRUPTS
    T1CON = %11111100 'config timer1
    Symbol TMR1ON = T1CON.0
    '
    '************************************************* *****************************
    '
    ' S1 S2 S3 S4 bit time
    '1200 baud on on X X 800uS
    '2400 baud off on X X 400uS
    '9600 baud on off X X 100uS
    '19.2k baud off off X X 50uS
    '
    '************************************************* *****************************
    '
    Declare serial_data 8 ' USED FOR SERIN/SEROUT
    '
    Declare Hserial_Baud 4800'
    Declare Hserial_TXSTA $20 '$20 or $24
    Declare Hserial_RCSTA $90 '
    '
    Declare HSERIAL2_BAUD 4800'
    Declare Hserial2_TXSTA $20 '$20 or $24
    Declare Hserial2_RCSTA $90 '
    '
    Symbol N81_2400_True = 396 ' no parity, 8-bits, 1-stop, non-inv
    Symbol N81_2400_Inv = 16780 ' no parity, 8-bits, 1-stop, non-inv
    Symbol N81_4800_True = 188 ' no parity, 8-bits, 1-stop, non-inv
    Symbol N81_4800_Inv = 16572 ' no parity, 8-bits, 1-Stop, inv
    Symbol N81_9600_True = 84 ' no parity, 8-bits, 1-stop, non-inv
    Symbol N81_9600_Inv = 16468 ' no parity, 8-bits, 1-Stop, inv
    Symbol N81_19200_True = 32 ' no parity, 8-bits, 1-stop, non-inv
    J. Mark Wolf
    Pinckney, Michigan
    Rotorway 162F N1955Z
    Website:www.ucosm.com/helicopter

  10. #9


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    Tnx for the info i will try it out. Just one question. You have XTAL 20 and PLL enabled.

    So that gives you 80MHz? I have a 10MHz crystal and PLL enabled.

  11. #10


    Default Re: PIC 18F8722 Hserin2/Hserout2 problems

    No, there is actually a 10Mhz crystal on this particular module:

    (http://www.etteam.com/product/pic/ET...8F8722-Eng.pdf).

    I just defined the XTAL as "20" for purposes of the Mecanique bootloader, where the options are only "20" or "4". Then, as I recall, I had to delare the baud rates as "half-speed' (declaring 4800 baud would actually give 9600, etc).
    J. Mark Wolf
    Pinckney, Michigan
    Rotorway 162F N1955Z
    Website:www.ucosm.com/helicopter

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. HSerout2 - Configurations
    By fgcity in forum Proton Plus Compiler v3
    Replies: 17
    Last Post: 18th January 2012, 10:27
  2. 18F8722 Speed Problem
    By GamaxiTRONIX in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 3rd August 2009, 08:27
  3. SPI1 on 18F8722
    By SELCUK in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 12th December 2007, 09:58
  4. A/D on 18F8722
    By ilias in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 5th July 2006, 15:14
  5. 18f8722
    By Mr Anderson in forum Proton Plus Compiler v3
    Replies: 23
    Last Post: 26th January 2006, 00:34

Members who have read this thread since 17th May 2012, 19:21 : 0

Actions :  (Set Date)  (Clear Date)

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