SEROUT2 broken on 18F4620 ?


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Nicely spotted Acetronics.

    Changing to TRISE=%00000111 should do the trick. (Or just remove the line altogether since %0000111 is it's power on / reset value anyway.)
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  2. #2
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    OK, I'll give that a bash shortly (when my first morning coffee has taken effect).

    In my defense though, I originally had the Serout2 working on PortA.0 and it wouldn't work there, and I did have the TRIS bits set for Outputs at that time. After all, the Serout2 code was working fine on the 18F1220 and was on PortA.0.

    After that (portA) I tried PortE.0 and PortD.0, but didn't swap the TRIS bits, that how the code was left.
    Doesn't PBP force the pin to an output anyway even if not set in the TRIS statement ?

    Talk to you soon.

  3. #3
    sinoteq's Avatar
    sinoteq Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mr.sneezy View Post
    Doesn't PBP force the pin to an output anyway even if not set in the TRIS statement ?
    Normally PBP takes care of it but you enabled Parallel Slave Port by using TRISE and a few extra "1" By doing this you kill the PortD function of the PortD port and make it to a 8 bit super special data bus and PBP have absolutly no idea.

    It is really good to make your own TRIS statements you were just a bit unlucky

  4. #4
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default The plot thickens....

    OK, I've spent about three hours on this now, and I have made some progress, and no, all the suggestions above didn't turn out to be the cause, I tried all the Tris changes suggested, then rem'd them all out as well.
    However I have not pin-pointed the exact problem yet... (and my caffine level has dropped to 'critical', so I must take a break)

    I stripped my code down to nothing but my configs, a LED flash and a couple of Serout2 text strings, and put the Serout2 back on PortA. Still it failed to Serout...

    Then I stripped out my configs, and unremarked the defaults in PBP's 18F4620 inc file (made changes to OSC and MCLRE to suit me). And.... Serout2 came back to life.

    I then put my configs back, and rem'd out the INC files entries. Serout2 dies (LED still flashes correctly).
    So unless I'm being tricked somehow, by me being very pedantic with my list of configs I've broken something very subtle somehow.

    Here is my configs, and the PBP defaults. If anyone knows which of my configs could hurt PBP compiler please let me know.... To try each config in turn randomly will take ages.

    Code:
    'My Config Directive settings for MPASM (fuses) for 18F4620 (that don't work with Serout2)
     
    @    __CONFIG  _CONFIG1H, _IESO_OFF_1H & _FCMEN_OFF_1H & _OSC_INTIO7_1H
    @    __CONFIG  _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L 
    @    __CONFIG  _CONFIG2H, _WDT_OFF_2H & _WDTPS_32_2H
    @    __CONFIG  _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H
    @    __CONFIG  _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVREN_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, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
    @    __CONFIG  _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
    @    __CONFIG  _CONFIG7H, _EBTRB_OFF_7H

    PBP's configs, that do work.
    Code:
     INCLUDE "P18F4620.INC"	; MPASM  Header
            __CONFIG    _CONFIG1H, _OSC_INTIO7_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H 
    
    & _MCLRE_OFF_3H
            __CONFIG    _CONFIG4L,  _STVREN_ON_4L & _LVP_OFF_4L & XINST_OFF_4L
    My code stripped down
    Code:
    ' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    'Config Directive settings for MPASM (fuses) for 18F4620
     
    @    __CONFIG  _CONFIG1H, _IESO_OFF_1H & _FCMEN_OFF_1H & _OSC_INTIO7_1H
    @    __CONFIG  _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L 
    @    __CONFIG  _CONFIG2H, _WDT_OFF_2H & _WDTPS_32_2H
    @    __CONFIG  _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H
    @    __CONFIG  _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVREN_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, _WRTC_OFF_6H & _WRTB_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 8 '8Mhz clock used.
       
        SO          Var     PortA.2        'Serial out pin
        LED         var     PortA.1        'Indicator LED, via 500ohm to +3.3V
    
        
    ' Initialise Processor - check for each PIC type 
    ' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    '    ADCON1 = %00001111              'Turn off all AD's     
        OSCCON =  %01100111     'set INTRC to 4 MHZ    
    '    OSCCON = %01110111     'set INTRC to 8 MHZ
    '    OSCTUNE = 0                      'OSC trim set to Null 
    ' Set initial state of port pins as Input or Output
    
    '    TRISA = %11111100    'Input(0 = output, 1 = Input)
    '    TRISB = %11111100    '
    '    TRISC = %11111111
    '    TRISD = %11111110
    '    TRISE = %11111111
        
    ' PIC initialization code
    '        Low So      'Must start low, or you get rubbish on the LCD at PIC boot up.
    '        Gosub Alive
            Low LED     'LED on
            pause 500  'led on for x seconds
            High LED    'LED off
            Pause 500
            Low LED     'LED on
            pause 500  'led on for x seconds
            High LED    'LED off 
                    
            Serout2 SO,16780,[$FE,$01]               ' Clear LCD & home LCD cursor.
            pause 10                                ' wait for LCD to catch up
            Serout2 SO,16780,["   FrSky Vario    "]  ' Serial print 
            Serout2 SO,16780,[$FE,$C0]               ' Shift cursor to line2
            Serout2 SO,16780,[" Development Jig  "]  ' Serial print 
            Pause 5000                               'wait three seconds        
            
    End
    Last edited by mr.sneezy; - 30th May 2010 at 06:59.

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    If the default configs work, is there any reason you cant just use them? If there are any configs that you definitely need to change from default, then simply change them one at a time so you know if one of them breaks it.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  6. #6
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    I like to know whats going on, so I did it the hard way...

    This config line kills Serout2 functionality.
    @ __CONFIG _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVREN_OFF_4L

    This line restores it.
    @ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L

    Drilling down to individual config parameters, if I add this one to my original list Serout2 works again.
    & _XINST_OFF_4L

    The datasheet refers to this as an Extended Instruction set enabling bit. I read a bit about it, and it's use is way beyond my comprehension.

    What the ?
    And why does it just break the Serout2 command and not everything else in PBP too ?

    It's days like these I really wonder why we bothered coming out of caves and inverting the wheel anyway, it would have been much less pain just staying in a nice warm cave

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Sneezy

    Here's the reason ...

    PBP defaults :
    INCLUDE "P18F4520.INC" ; MPASM Header
    ;__CONFIG _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    ;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    ;__CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    ;__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    so, "PBP" is supposed to clear this config bit ... but you remmed those lines :

    BUT ...

    MPASM defaults it to OFF ...

    Sooooo, What happend ??? how did it turn on by itself ???

    Conclusion ... do not forget to explicitly turn OFF XTINST in your config.

    Further explanations can be found in Datasheet $24 ( a bit over my own head ...I admit ! )


    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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