• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Attempting a "hello world" with a PIC16LF15313

Not open for further replies.

Beau Schwabe

Active Member

I am using MPLAB X IDE (V4.01) on a Linux system and a PicKit 3, and all is good with 4 of the 6 I/O's on the PIC16LF15313 but I can't seem to properly configure PA3 and PA5 as outputs. PA0, PA1, PA2, and PA4 all test ok. Any clues would be helpful as there doesn't seem to be much in the way of example code for this micro that I have been able to find.

Here is a code snip that will configure PA4 as an output and wiggle the pin at about 167kHz ... Thanks again for any help !!

#include "p16lf15313.inc"
    org       0
    goto    Init
    org       100
    movlw   b'00000000'
    movwf   ANSELA

    movlw   b'00000000'
    movwf   ODCONA
    movlw   b'00000000'
    movwf   LATA
    movlw   b'00000000'
    movwf   TRISA

    bsf   PORTA,4       ;0,1,2,4  Works for these but I also need 3 and 5
    bcf   PORTA,4
    goto Main
Last edited by a moderator:


Well-Known Member
Is there a particular reason you are using this chip ?

Though good , many of these newer devices are so multi functional they can be difficult get going with them and the few examples you see are in C.

If doing good old Assembly, then look at chips like 16F - 84A, 628A, 88 , 876A and 877A which have lots of assembly code, tutorials and projects based upon them.


Well-Known Member
Most Helpful Member
ANSELA is in Bank 62 . You might try a banksel instruction before setting it. Also, I note that LATA is now in Bank 0 along with PORTA . Try controlling your outputs with LATA (remember, read a port, write a latch). On earlier chips, LATA is in Bank 2 and you can often get away with writing to the port. I have no experience with your chip, but it might be worth a try.

Beau Schwabe

Active Member
Thanks guys.... The datasheet is a little misleading since it refers to PA0 to PA5 as all being configurable I/O's .... I assumed they could all be used for output even if it were an open drain output that would be ok.

Why this chip? Well the price point was good along with the number I/O's but the original attraction was the 10-bit ADC capabilities on 5 of the I/O's .... I also needed some NV memory that I could write to... not a huge amount just enough for some set and forget configurability.... The builtin I2C was also a plus in addition to USART Now, except for the memory, I suppose I could bit bang all of that. However the scope of the design has changed slightly, and I don't really need the ADC capabilities and I could manage with 4 I/O's and 2 I's .... besides I already purchased 25 of these IC's

I have actually been programming for quite sometime (Early 90's) , only I have mostly stuck with the older chips .... I decided to venture out a little bit to play with some of the newer chips out there. I prefer pure Assembly, I'm just old school that way.


Well-Known Member
If you look at the data sheet you have 5 output's push pull or open drain. mclr input with weak pullup.
Not open for further replies.

Latest threads

EE World Online Articles