# Attempting a "hello world" with a PIC16LF15313

Status
Not open for further replies.

#### Beau Schwabe

##### Active Member
Hello,

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

Code:
#include "p16lf15313.inc"

CONFIG1 = _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
CONFIG2 = _MCLRE_OFF & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_ON & _STVREN_ON
CONFIG3 = _WDTCPS_WDTCPS_31 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_SC
CONFIG4 = _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_ON
CONFIG5 = _CP_OFF

org       0
goto    Init

org       100
Init:
movlw   b'00000000'
movwf   ANSELA

movlw   b'00000000'
movwf   ODCONA

movlw   b'00000000'
movwf   LATA

movlw   b'00000000'
movwf   TRISA

Main:
bsf   PORTA,4       ;0,1,2,4  Works for these but I also need 3 and 5
nop
nop

bcf   PORTA,4

goto Main

end

Last edited by a moderator:

#### Pommie

##### Well-Known Member
A3 is input only. Check a5 in datasheet.

#### Wp100

##### 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.

#### jpanhalt

##### Well-Known 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.

#### be80be

##### 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.

Status
Not open for further replies.

Replies
5
Views
5K
Replies
10
Views
2K
Replies
14
Views
6K
Replies
25
Views
4K
Replies
7
Views
1K