• AVR Freaks

AnsweredHot!Can you use RA3 on PIC16(L)F15313 as a digital output

Author
Christopher_Ash
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2019/01/31 07:08:56
  • Location: 0
  • Status: offline
2019/02/25 13:54:41 (permalink)
0

Can you use RA3 on PIC16(L)F15313 as a digital output

Hello,
   I am trying to figure out if it is possible to use the RA3 pin on the PIC16LF15313 as a digital output. This pin is multiplexed as the MCLR for the PIC, however I turned off the MCLRE setting in the configuration bits and I still can't get it to work as an output. I am not seeing a TRIS3 bit while trying to code the PIC, therefore I am trying to figure out if it is possible to use this pin as a digital output. Please see my code below for my attempt at using it which currently does not work. Thank you for your time. My apologies for any trivial mistakes in advance.
 
/*
 * File: newmain.c
 * Author: Christopher
 *
 * Created on January 29, 2019, 11:52 AM
 */
// CONFIG1
#pragma config FEXTOSC = OFF // External Oscillator mode selection bits (Oscillator not enabled)
#pragma config RSTOSC = HFINT32 // Power-up default value for COSC bits (HFINTOSC with OSCFRQ= 32 MHz and CDIV = 1:1)
#pragma config CLKOUTEN = OFF // Clock Out Enable bit (CLKOUT function is disabled; i/o or oscillator function on OSC2)
#pragma config CSWEN = OFF // Clock Switch Enable bit (The NOSC and NDIV bits cannot be changed by user software)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (FSCM timer enabled)

// CONFIG2
#pragma config MCLRE = OFF // Master Clear Enable bit (MCLR pin is Master Clear function)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config LPBOREN = OFF // Low-Power BOR enable bit (ULPBOR disabled)
#pragma config BOREN = OFF // Brown-out reset enable bits (Brown-out reset disabled)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices)
#pragma config ZCD = OFF // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR.)
#pragma config PPS1WAY = OFF // Peripheral Pin Select one-way control (The PPSLOCK bit can be set and cleared repeatedly by software)
#pragma config STVREN = OFF // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will not cause a reset)

// CONFIG3
#pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS)
#pragma config WDTE = OFF // WDT operating mode (WDT Disabled, SWDTEN is ignored)
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = SC // WDT input clock selector (Software Control)

// CONFIG4
#pragma config BBSIZE = BB512 // Boot Block Size Selection bits (512 words boot block size)
#pragma config BBEN = OFF // Boot Block Enable bit (Boot Block disabled)
#pragma config SAFEN = OFF // SAF Enable bit (SAF disabled)
#pragma config WRTAPP = OFF // Application Block Write Protection bit (Application Block not write protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot Block not write protected)
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration Register not write protected)
#pragma config WRTSAF = OFF // Storage Area Flash Write Protection bit (SAF not write protected)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (High Voltage on MCLR/Vpp must be used for programming)

// CONFIG5
#pragma config CP = OFF // UserNVM Program memory code protection bit (UserNVM code protection disabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#define _XTAL_FREQ 32000000

#include <xc.h>

void main(void){
    ANSELA = 0; //sets all of the pins as digital I/Os
    
    
    
    while(1){
        PORTAbits.RA3 = 1;
        __delay_ms(1000);
        PORTAbits.RA3 = 0;
        __delay_ms(1000);
    }
    return;
}

#1
jack@kksound
code tags!
  • Total Posts : 3188
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Can you use RA3 on PIC16(L)F15313 as a digital output 2019/02/25 14:33:22 (permalink) ☄ Helpfulby Christopher_Ash 2019/02/25 14:55:48
+2 (2)
If there is no TRISx bit for the pin it is a pretty good bet the pin is input only. Also no LATA3 bit would indicate that this is an input only pin. Many datasheets will specifically state that the MCLR pin is input only, this one does not appear to do so. ERRATA sheet also lists no clarification of this. THere is also no analog capability on this pin. All of this is very common for the MCLR/Vpp pin.
#2
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Can you use RA3 on PIC16(L)F15313 as a digital output 2019/02/25 14:38:29 (permalink) ☼ Best Answerby Christopher_Ash 2019/02/25 14:55:45
+3 (3)
Christopher_Ash
   I am trying to figure out if it is possible to use the RA3 pin on the PIC16LF15313 as a digital output.

No, that pin is input only.
There is a mistake in  "TABLE 1-2" in the datasheet, which indicates "CMOS/OD" as the "output type".
This is wrong. The lack of bits in the TRISA, LATA, ODCONA and SLRCONA registers indicate that this pin can NOT act as an output.
The only glimmer of hope if you have run out of pins is that you can control the weak pullup resistor on that pin, so if you add a high value pulldown resistor, and buffer the signal, then you can produce another output by switching the pullup off and on.
 

Nearly there...
#3
Christopher_Ash
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2019/01/31 07:08:56
  • Location: 0
  • Status: offline
Re: Can you use RA3 on PIC16(L)F15313 as a digital output 2019/02/25 14:57:27 (permalink)
0
Thank you all so much. I can just rearrange some pins an use RA3 as a digital input instead. Thank you again for your help.
#4
Jump to:
© 2019 APG vNext Commercial Version 4.5