PoortC problem with 18F25K50


+ Reply to Thread
Results 1 to 7 of 7

Thread: PoortC problem with 18F25K50816 days old

  1. #1
    Hemsys
    Guest Hemsys's Avatar

    0 Not allowed!

    Default PoortC problem with 18F25K50

    Hi all,

    I have a problem with a very simple pice of code.
    Hope that someone can help me.
    It looks like the program is not detecting the high input on poort C2 en C7, but if I check with a scope the line is high.
    But the the output B0 and B2 newer get high.
    The toggle on poort C1 is working, so the program is running.
    It only is going wrong with poort C.
    If I simulate with MPLAB everything is working fine.
    Compiled wiht Compiler. Ver 3.6.0.2


    Here is the code.

    Device = 18F25K50
    Config_Start
    PLLSEL = PLL4X ;4x clock multiplier
    CFGPLLEN = On ;PLL Enabled
    CPUDIV = NOCLKDIV ;CPU uses system clock (no divide)
    LS48MHZ = SYS48X8 ;System clock at 48 MHz, USB clock divider is set to 8
    FOSC = HSH ;HS oscillator, high power 16MHz to 25MHz
    PCLKEN = OFF ;Primary oscillator enabled
    FCMEN = OFF ;Fail-Safe Clock Monitor disabled
    IESO = OFF ;Oscillator Switchover mode disabled
    nPWRTEN = OFF ;Power up timer disabled
    BOREN = SBORDIS ;BOR enabled in hardware (SBOREN is ignored)
    BORV = 190 ;BOR set to 1.9V nominal
    nLPBOR = OFF ;Low-Power Brown-out Reset disabled
    WDTEN = OFF ;WDT disabled in hardware (SWDTEN ignored)
    WDTPS = 32768 ;1:32768
    CCP2MX = RC1 ;CCP2 input/output is multiplexed with RC1
    PBADEN = OFF ;PORTB<5:0> pins are configured as digital I/O Reset
    T3CMX = RC0 ;T3CKI function is on RC0
    SDOMX = RC7 ;SDO function is on RB3
    MCLRE = OFF ;RE3 input pin enabled; external MCLR disabled
    STVREN = OFF ;Stack full/underflow will cause Reset
    LVP = OFF ;Single-Supply ICSP disabled
    ICPRT = OFF ;ICPORT disabled
    XINST = OFF ;Instruction set extension and Indexed Addressing mode disabled
    Debug = OFF ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
    Cp0 = OFF ;Block 0 is not code-protected
    CP1 = OFF ;Block 1 is not code-protected
    CP2 = OFF ;Block 2 is not code-protected
    CP3 = OFF ;Block 3 is not code-protected
    CPB = OFF ;Boot block is not code-protected
    CPD = OFF ;Data EEPROM is not code-protected
    WRT0 = OFF ;Block 0 (0800-1FFFh) is not write-protected
    WRT1 = OFF ;Block 1 (2000-3FFFh) is not write-protected
    WRT2 = OFF ;Block 2 (04000-5FFFh) is not write-protected
    WRT3 = OFF ;Block 3 (06000-7FFFh) is not write-protected
    WRTC = OFF ;Configuration registers (300000-3000FFh) are not write-protected
    WRTB = OFF ;Boot block (0000-7FFh) is not write-protected
    WRTD = OFF ;Data EEPROM is not write-protected
    EBTR0 = OFF ;Block 0 is not protected from table reads executed in other blocks
    EBTR1 = OFF ;Block 1 is not protected from table reads executed in other blocks
    EBTR2 = OFF ;Block 2 is not protected from table reads executed in other blocks
    EBTR3 = OFF ;Block 3 is not protected from table reads executed in other blocks
    EBTRB = OFF ;Boot block is not protected from table reads executed in other blocks
    Config_End

    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
    ;
    ; We are running at 12 Mhz external crystal with 33pF
    ;
    ;-----------------------------------------------------------------------------
    Declare Xtal = 48
    Declare Create_Coff = On ; for debugging in MPLAB
    Declare All_Digital = True
    TRISA = %01000000 ;
    LATA = %01000000 ;
    ; ;
    TRISB = %00000000 ;
    LATB = %00000000 ;
    ;
    LATC = %11000111
    TRISC = %11000111
    ;
    PORTE = 1 ;
    ;
    ;================================================= ==========================
    ; MAIN LOOP !!!!!!!!!!!!
    ;================================================= ==========================
    ;================================================= ==========================
    lus:
    Toggle PORTC.1
    If PORTC.2 = 1 Then
    PORTB.0 = 1
    Else
    PORTB.0 = 0
    EndIf
    If PORTC.7 = 1 Then
    PORTB.2 = 1
    Else
    PORTB.2 = 0
    EndIf
    GoTo lus
    End

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,458
    Thumbs Up
    Received: 71
    Given: 26
    Total Downloaded
    6.08 GB

    0 Not allowed!

    Default Re: PoortC problem with 18F25K50

    Try to change these: -

    Code:
    TRISB = %00000000 ; 
    LATB = %00000000 ;
    ; 
    LATC = %11000111 
    TRISC = %11000111
    to: -

    Code:
    TRISB = %00000000 ; 
    PORTB = %00000000 ;
    ; 
    
    TRISC = %11000111 
    PORTC = %00000000
    Also make sure you have pull down on your PORTC.

    I would not trust the All_Digital = True. I would go through the data sheet and set the registers manually.
    Last edited by joesaliba; 27th August 2017 at 17:09.
    Regards

    Joseph

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Hemsys
    Guest Hemsys's Avatar

    0 Not allowed!

    Default Re: PoortC problem with 18F25K50

    Hi Joseph,


    Thangs for the reply.
    I have tried your code, but it is not the solution.

    Regards,
    Henk

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Hemsys
    Guest Hemsys's Avatar

    0 Not allowed!

    Default Re: PoortC problem with 18F25K50

    Hi Joseph,

    I overlooked your statement of not trust All_Digital = True.
    So I have put te next 3 extra lines in the code
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0
    And now its working!!!!
    thank you again for your reply.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    Member John Lawton's Avatar
    Join Date
    Feb 2003
    Posts
    270
    Thumbs Up
    Received: 5
    Given: 14
    Total Downloaded
    1.35 GB

    0 Not allowed!

    Default Re: PoortC problem with 18F25K50

    Your ports are not in digital mode.

    For the 25K22 I use this
    Code:
    ' Latches all disabled:
        SRCON0 = 0
        SRCON1 = 0
    
    ' Comparators all disabled:
        CM1CON0 = 0
        CM2CON0 = 0
        CM2CON1 = 0
     
    ' Vital:
        ANSELA = 0
        ANSELB = 0
        ANSELC = 0
    
        SLRCON = 0  'port edges NOT slowed down
    which you may need to extend as the 25K50 is a larger device with more ports. Read section 11 of the data sheet on I/O ports which tells you about these settings.

    John

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Re: PoortC problem with 18F25K50

    What version of the compiler are you using?

    The latest versions make pins digital before the program actually runs, and the code is located in each device's .def file. For the 18F25K50, the BASIC code in the .def file is:

    Code:
    '-----------------------------------------------------------------------------------
    ' Make the device's I/O pins digital (if required) before the main program starts
    ' This can be added too by the user and shared on the forum
    '
        ANSELA = $00
        ANSELB = $00
        ANSELC = $00
        CM1CON0 = $00
        CM2CON0 = $00
    In the asm of a simple test program, the above code turns into:

    Code:
        movlb 15
        clrf  ANSELA ,1
        clrf  ANSELB ,1
        clrf  ANSELC ,1
        clrf  CM1CON0 ,0
        clrf  CM2CON0 ,0
    Main
        movlb 0
    That's why the All_Digital declare is no longer required, as the user can alter the SFRs if required, then post on the forum any changes, which will be validated then added to the next compiler's update etc...

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    Hemsys
    Guest Hemsys's Avatar

    2 Not allowed!

    Default Re: PoortC problem with 18F25K50

    Les,
    Compiled with Compiler. Ver 3.6.0.2.
    But is working now, after the next 3 lines.
    ANSELX = 0

    But I must say that I had done a update from the compiler to version 3.6.0.2 after the reply from Joseph.
    And at the same time put the 3 ANSELX = 0 lines in the code as Joseph suggested.
    I will test it again without the 3 ANSELX = 0 lines but with the updated compiler.

    Regards
    Henk

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. [SOLVED !] Problem with 3.7.2.8 and 18F25K50
      By towlerg in forum Proton Plus Compiler v3
      Replies: 9
      Last Post: 15th October 2019, 14:46
    2. CWRITE and 18F25K50
      By See_Mos in forum Proton Plus Compiler v3
      Replies: 9
      Last Post: 5th September 2019, 15:56
    3. Unable to get 18F25K50 and new USB stack working
      By See_Mos in forum USB Module
      Replies: 8
      Last Post: 2nd March 2017, 18:17

    Members who have read this thread : 30

    Actions :  (Set Date)

    You do not have permission to view the list of names.

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts