16F1829 PORTA.5 problem
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2016
    Posts
    51

    Default 16F1829 PORTA.5 problem

    Hello Folks,
    I'm struggling a few days how to set port RA5 on PIC 16F1829 as general purpose I/O (output).
    I try everything but no succes, I think the problem is around oscillator configuration, because the pin still in CLKIN state (or something else), not as gen. purpose I/O.
    Please, can someone help me with proper configuration.
    Here is the test code, and config:
    Code:
    ; MCU PIC16F1829                                        
      
    #CONFIG
    cfg= _FOSC_INTOSC
    cfg&= _WDTE_OFF
    cfg&= _PWRTE_OFF
    cfg&= _MCLRE_OFF
    cfg&= _CP_OFF
    cfg&= _CPD_OFF
    cfg&= _CLKOUTEN_OFF
    cfg&= _IESO_OFF 
    cfg&= _FCMEN_OFF
    #ENDCONFIG
    
    DEFINE OSC 8     ; Use a 8 MHZ internal clock 
    OSCCON = %01110000
    CLKRCON = 0
    APFCON0 = 0   
    APFCON1 = 0
    CM1CON0 = 0
    
    CCP1CON = %00000000
    CCP2CON = %00000000
    ANSELA = %00000000
    ANSELB = %00000000
    ANSELC = %00000000
    TRISA = %000000
    TRISB = %00000000      
    TRISC = %00000000
    CM1CON0 = 0       ; Disable comparator 1
    CM2CON0 = 0       ; Disable comparator 2 
    OPTION_REG.6=0
    OPTION_REG.7=1
    
    led var porta.5
    
    main:
    high led
    pause 500
    low led
    pause 500
    goto main

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,603

    Default Re: 16F1829 PORTA.5 problem

    you have not programmed config word2 , my pickit2 spits the dummy over the missing code word

    Code:
    #CONFIG
    cfg= _FOSC_INTOSC
    cfg&= _WDTE_OFF
    cfg&= _PWRTE_OFF
    cfg&= _MCLRE_OFF
    cfg&= _CP_OFF
    cfg&= _CPD_OFF
    cfg&= _CLKOUTEN_OFF
    cfg&= _IESO_OFF 
    cfg&= _FCMEN_OFF
    #ENDCONFIG
    with a proper config section your code loads and functions , mind you there is heaps of unnecessary stuff in it

    my take
    Code:
                                        
    #CONFIG
      __config  _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
      __config  _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_19 & _LVP_OFF
    #ENDCONFIG
    
    
    DEFINE OSC 8     ; Use a 8 MHZ internal clock 
    OSCCON = %01110000
    
    
    
    
    
    
    ANSELA = 0
    
    
    TRISA = %11011111
    
    
    
    
    
    
    led var porta.5
    
    
    main:
    high led
    pause 500
    low led
    pause 500
    goto main
    Last edited by richard; - 10th March 2019 at 00:29. Reason: readibility
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Mar 2016
    Posts
    51

    Default Re: 16F1829 PORTA.5 problem

    Thank you Richard, it works.
    I spent a lot of time reading the datasheet how to configure ports, oscillators etc. but still nothing.
    You helped me a lot. Great, as usual.
    Louis

Similar Threads

  1. Trying to inch my way to the finish line w/ a 16F1829.........
    By thasatelliteguy in forum mel PIC BASIC Pro
    Replies: 67
    Last Post: - 30th June 2014, 23:55
  2. Replies: 2
    Last Post: - 31st May 2013, 18:19
  3. portA problem
    By keymuu in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 15th October 2008, 16:48
  4. PortA.4 problem
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th April 2005, 16:09
  5. PORTA.PinNo = 1 ' problem
    By frank small in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th May 2004, 14:30

Members who have read this thread : 15

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