Multiple problems with PIC16LF15313
I'm trying to migrate a program to a new small chip I have never used before. I have had multiple problems with it and am beginning to suspect there might be some sort of problem with the MPASM include file or the something else under the hood that I'm not familiar enough to figure out on my own.
I have stripped the program down to the basics. I verify a heartbeat at the beginning with an LED then I made a main loop to basically do nothing with an x = 0 goto main loop. When I do this, there is about a 2-3 second pause after the heartbeat and then the program seems to time out and restart. I assume the watchdog is being triggered. It goes on forever this way. ran a faster heartbeat within the mainloop and it worked as expected. I After a lot of random trial and error I found that if I added a pauseus 1 command it would stop resetting. I didn't really want to add this statement, but could live with it. The program below is one step above that where I'm trying to monitor 1 pin and mimic the state on another pin and no matter what I do the read always acts as if the pin is low. I've used a volt meter to verify changes in hardware and have tested on multiple boards and am not having any luck. I triple checked my schematic pin outs match the data sheet. If anyone has any suggestions I would appreciate it
Code:
DEFINE OSC 32
'no changes made to any config settings so far 6-26-2020
#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
__config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_6 & _WDTCCS_HFINTOSC
__config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
__config _CONFIG5, _CP_OFF
#ENDCONFIG
TRISA = %1111010 'output on 0,2. input on remainder
OUT_SIG var LATA.0 'PORTA.0 'output to input chip
CL_LED var LATA.2 'PORTA.2 'blink LED when current loop changes
RS_SIG var PORTA.1 '232 and 422 combined signal
CLOOP VAR PORTA.5 'current loop
X var byte
'heartbeat
for x = 0 to 1
CL_LED = 0
pause 500
CL_LED = 1
pause 500
next x
Mainloop:
pauseus 1
CL_LED = RS_SIG
goto mainloop
end
Re: Multiple problems with PIC16LF15313
trying to use a chips pins as digital i/o when they are still configured as analogue is never a recipe for success
Re: Multiple problems with PIC16LF15313
I believe these newer PICs default to analog inputs. Try:
ANSELA = 0
Re: Multiple problems with PIC16LF15313
Quote:
Originally Posted by
mpgmike
I believe these newer PICs default to analog inputs
i'd be astonished if you could find a pbp supported chip that doesn't default to analog
Re: Multiple problems with PIC16LF15313
This also sounds like the MCLR pin may not be tied high.
Re: Multiple problems with PIC16LF15313
Thanks everyone. I'll try that in a couple hours, but you are probably correct. I was migrating from a 16F54, which didn't have analog options on the pins I was using, so when I was updating all the registers, I didn't think about adding new registers. I'm pretty sure you guys are correct though. I did have MCLR tied high. There must be some analog conversion going on that causes the unit to reset and somehow the pauseus command is enough to prevent it, but it isn't worth investigating if going digital cleans it all up.
Thanks again.
:biggrin: