PORTC Weak Pull-ups on PIC16F1503


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172

    Default PORTC Weak Pull-ups on PIC16F1503

    Hi All,

    I am making good inroads programming the PIC16F1503.
    I am able to set Timer1 and IOC interrupts with Darrel's DT_INT routine and can flash LED's at appropriate rates but I have hit a snag setting up weak pull-ups on PORTC.
    I can set up weak pull-ups on PORTA but I get a syntax error message when compiling with a weak pull-up on PORTC setting.
    My code is as follows:

    Code:
    #CONFIG
            __config _CONFIG1, _FOSC_INTOSC & _MCLRE_OFF & _CP_OFF & _CLKOUTEN_OFF
            __config _CONFIG2, _LVP_OFF & _LPBOR_OFF
    #ENDCONFIG
    
    OSCCON = %01101000              ; Fosc = 4MHz
                                    ; Clock determined by Fosc<1:0> Config Word
    DEFINE OSC 4                    ; Define socillator as 4MHz
    
    ' Included the interrupt system
    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ISR,   PBP,  yes
        endm
        INT_CREATE            ; Creates the interrupt processor
    ENDASM
    
    
    @   INT_ENABLE  TMR1_INT  ; Enable Timer 1 Interrupts
    
                                    
    ANSELA = 0                      ; Disable PORTA ADC
    ANSELC = 0                      ; Disable PORTC ADC
    DACCON0.7 = 0                   ; Disable DAC
    CM1CON0.7 = 0                   ; Disable comparator 1
    CM2CON0.7 = 0                   ; Disable comparator 2
    T1CON = %00110000               ; Fosc/4
                                    ; 1:8 Prescaler
                                    ; Timer1 OFF
    T1GCON.7 = 0                    ; Timer1 counts regardless of gate function
    TRISA = %00011000               ; PORTA.3 and PORTA.4 as inputs
    TRISC = %00001101               ; PORTC.0, PORTC.2 and PORTC.3 as inputs
    OPTION_REG.7 = 0                ; Enable Weak Pull-ups
    WPUA = %00011000                ; Pull-ups on PORTA.3 and PORTA.4WPUC = 1 
    WPUC = %00001101                ; Pull-ups on PORTC.0, PORTC.2 and PORTC.3
    IOCAP = %00011000               ; IOC positive edge register PORTA.3 + PORTA.4
    IOCAN = %00011000               ; IOC negative edge register PORTA.3 + PORTA.4
    The compiler reports a syntax error at the WPUC = %00001101 statement.
    No problems with the WPUA = %00011000 statement so I am bewildered.
    The datasheet clearly states how to use the WPUC register and I believe I have followed the instructions correctly.
    Am I missing something?

    I am using Microcode Studio Version 5.0.0.0, PBP3.0.5.4 and MeLabs U2 programmer.

    Any assistance would be greatly appreciated.

    Cheers
    Barry
    VK2XBP

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Hi, Barry

    you're right

    WPUC definition is missing in the .PBPINC file ...

    you can add it yourself if you want ( C:\PBP3\DEVICES\PIC16F1503.PBPINC file)

    PBP Team : To be corrected fo Next release
    Alain

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Ok Alain,

    If you can tell me what address that register is in, it will be added.

    I'm betting you won't find that little bit of information.
    DT

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    I guess Alain doesn't want to play.
    Instead, he posted a bug report in the melabs forum without doing any research.

    So Barry,
    The 16F1503 doesn't have a WPUC register.

    Yes, I know you'll find references to WPUC in the datasheet ... but it doesn't exist.
    There is a WPUA, but no WPUC.

    If you need pull-ups on PORTC, they'll have to be external.
    DT

  5. #5
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Hi Darrel,

    I did a bit of searching on this subject and found some conflicting information.
    Microchip has released an errata document stating WPUC is not available for the PIC16F1503 but I also found another forum where a member had successfully implemented WPUC at H.'020E'
    http://www.microchip.com.edgekey.net...051-print.aspx

    I am not sure who to believe.
    I really don't have room on my board for external pull-up resistors. I chose the PIC16F1503 because it was reported to have weak pull-ups on both PORTA and PORTC.
    Is a workaround possible using H.'020E' address?

    Cheers
    Barry
    VK2XBP

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    The person that said he got PORTC pull-ups to work on a 16F1503, has a total of 1 post on that forum.
    Completely unreliable source.

    The register, and the pull-ups do not exist in hardware.
    No amount of messing with the code will change that fact.

    Attempting to write to that address will result in errors from the assembler.
    You can use the FSR's to indirectly write to address 020E ... but no pull-ups will activate on PORTC, because they're not there.
    And when you read it back it returns all 0's.
    I have actually done that with a 16F1503.

    Quote Originally Posted by Aussie Barry
    I am not sure who to believe.
    I'm Crushed!
    DT

  7. #7
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Hi Darrel,

    Thanks for the prompt reply and detailed explanation.
    Please do not feel crushed. My comments were from complete despair and were not directed at you. I should have known better than to question your reply but I read that someone had managed to achieve what I wanted to do and I saw a glimmer of hope on the horizon.

    Time for a re-think on how to achieve my desired result. Thankfully, I do like a good challenge

    Cheers
    Barry
    VK2XBP

  8. #8
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Perhaps I should look at using PIC16F1823 instead of the PIC16F1503?

    Darrel, are you aware of any issues with WPUC on the PIC16F1823?

    Cheers
    Barry
    VK2XBP

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    On the 16F1823 ... the weak pull-ups on PORTC work fine.
    DT

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Quote Originally Posted by Darrel Taylor View Post
    I guess Alain doesn't want to play.
    Instead, he posted a bug report in the melabs forum without doing any research.
    Apologies, Darrel ...

    I 've forgotten to download their ....GRRRRR ... F... errata sheet !!!
    errata happens so often it might automatically be included in the download ...

    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 " !!!
    *****************************************

  11. #11
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Hi All,

    I have now swapped over to PIC16F1823 for this project and I am now having difficulty using pins on PORTA as inputs with Weak Pull-ups enabled.
    I have stripped down my code as follows:

    Code:
    #CONFIG
            __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _BOREN_OFF
            __config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _WRT_HALF
    #ENDCONFIG
    
    OSCCON = %01101000              ; Fosc = 4MHz
                                    ; Clock determined by Fosc<1:0> Config Word
    DEFINE OSC 4                    ; Define oscillator as 4MHz
    
    ANSELA = 0                      ; Set PORTA as digital I/O
    ANSELC = 0                      ; Set PORTC as digital I/O
    ADCON0.0 = 0                    ; Disable ADC
    DACCON0.7 = 0                   ; Disable DAC
    CM1CON0.7 = 0                   ; Disable comparator 1
    CM2CON0.7 = 0                   ; Disable comparator 2
    CPSCON0.7 = 0                   ; Disable CPS module
    T1CON.7 = 0                     ; Timer1 OFF
    TRISC = 0                       ; All PORTC as outputs
    TRISA = 1                       ; All PORTA as inputa
    OPTION_REG.7 = 0                ; Enable Weak Pull-ups
    WPUA = %00111111                ; Pull-ups enabled on PORTA 
    
    
    LED1 var PORTC.5
    LED2 var PORTC.1
    
    Start:                          ; Flash LED1 and LED2 at 1Hz
    
    
        high LED1
        High LED2
        Pause 500
        low LED1
        low LED2
        pause 500
    
         
    Goto Start
    The program flashes LED1 and LED2 as expected but I get strange readings when I probe PORTA.1, .2, .4 or .5 with my oscilloscope.
    With PORTA set as digital inputs and weak pull-ups enables on PORTA I would expect those pins to read +5v but they are in fact reading 0v

    I need to connect switches to PORTA.2, .4 and .5 to make selections for my program to function but can't switch these pins to ground if they are already permanently there!

    Can anyone shed any light on what might be happening or what I might be doing wrong?

    Cheers
    Barry
    VK2XBP

  12. #12
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Except for PORTA.0, you've set all PORTA pins to OUTPUT mode.
    Code:
    TRISA = 1                       ; All PORTA as inputa
    By default at power-up, all pins are in INPUT mode.
    So unless you need to set a pin to output, you don't need to change the TRIS register.
    DT

  13. #13
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: PORTC Weak Pull-ups on PIC16F1503

    Oh Dear.....

    I just want to crawl into a hole and hide form the world...

    Thanks Darrel

Similar Threads

  1. Pull-ups on 16F88
    By Steves in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th June 2009, 10:19
  2. Weak pull-ups, WPU, and 12F683
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd February 2009, 22:14
  3. HELP on reading the data sheet/weak pull-ups
    By sbobowski in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th September 2008, 20:00
  4. PIC18F4550 internal pull-ups
    By Klaus in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th April 2008, 22:55
  5. Weak Pull-ups
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th June 2006, 19:41

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