PDA

View Full Version : PIC16F345 and DT_INTS-14



dran11
- 29th August 2025, 15:16
Hi,

Is there DT_INTS-14 that works with PIC16F345 ? I have tried to modify DT_INTS-14...changed few obvious difference's in #defines for timers 0/1/2 and and few more but LED blinky does not work. Is it possible to do it or 16F15xx are too much different ? By the way, code compiles, LCD out works but LED is not blinking.

Thank you,

richard
- 30th August 2025, 01:08
a pic16f345 is not a valid pic type, perhaps a simple schematic of your actual setup is called for and
then why don't you post the code you have tried. if you don't want to post the complete project then
aim to post the simplest compliable program that shows the problem. code snippets generally
don't cut it, we need to see the config settings, osc speed, var declarations, port settings etc....
[use code tags] please, if you don't know how to do that then read the faq

dran11
- 30th August 2025, 14:43
Sorry, it is PIC16F15345. Attached is modified DT_INTS-14 but does not work.



'
DISABLE DEBUG
#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_OFF
__config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _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
'
OSCFRQ = %101 ' 16mhz
DEFINE OSC 16
' lcd setup
DEFINE lcd_lines 4
DEFINE lcd_commandus 1500
DEFINE lcd_dataus 44
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 7
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 6
'
'-------------------- I/O ------------------------------------------------------
'
TRISC.4=1 ' input TASTER
TRISC.5=0 ' output LED1
ANSELA = %000000 ' ADC off all
ANSELB = %00000000 '
ANSELC = %00000000 '
'
'************************************************* ******************************
''************************* DT_INTS-14 *****************************************
'
INCLUDE "DT_INTS-14_16F15345-A.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
'
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
'
T1CON = $31 ; Prescaler = 8, TMR1ON
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
'
'-------------------------------------------------------------------------------
;-- Place a copy of these variables in your Main program -------------------
;-- The compiler will tell you which lines to un-comment --
;-- Do Not un-comment these lines --
;---------------------------------------------------------------------------
wsave VAR BYTE $20 SYSTEM ' location for W if in bank0
'wsave VAR BYTE $70 SYSTEM ' alternate save location for W
' ' if using $70, comment wsave1-3
'
' --- IF any of these three lines cause an error ?? ------------------------
' Comment them out to fix the problem ----
' -- Which variables are needed, depends on the Chip you are using --
wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1
wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2
wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3
'-------------------------------------------------------------------------------
'
'*************************** PIN NAMES *****************************************
TASTER VAR portC.4 '
LED1 VAR portC.5
'
' test program for PIC16F15345 with DT_INTS-14
' when button pressed, display "LED-blinky"
' TMR1 interupts toggle LED1
start:
GOSUB clearLCD
LCDOUT $FE,$80," TEST 16F15345"
LCDOUT $FE,$94," 20250825"
LCDOUT $FE,$D4," push button"
'
WHILE TASTER = 1 : WEND ' wait for pressed taster
PAUSE 500
'
GOSUB clearLCD
LCDOUT $FE,$80," LED-blinky"
'
Main:
PAUSE 1
GOTO Main
'
'************************************************* ******************************
'
clearLCD:
LCDOUT $FE,$01
RETURN
'
'---------------------[TMR1 - interrupt handler]--------------------------------
ToggleLED1:
TOGGLE LED1
@ INT_RETURN

richard
- 31st August 2025, 02:13
to start with you have not fully defined how the main OSC is setup i would add
OSCCON1 = $62;
secondly you have not set a clock source for timer1, as it is it expects a clock signal on the t1clk pps pin you probably don't want that
T1CLK = 1; ClockSource FOSC/4; 534mS
is more like it
thirdly the chip has auto context save for interrupts so wsave etc are not needed or even useful

i don't have a 16f15345 chip on hand and my simulator has no model for them either so the code is untested

but try this



#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_OFF
__config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _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
'


OSCCON1 = $62;
OSCFRQ = %101 ' 16mhz
DEFINE OSC 16
' lcd setup
DEFINE lcd_lines 4
DEFINE lcd_commandus 1500
DEFINE lcd_dataus 44
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 7
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 6
'
'-------------------- I/O ------------------------------------------------------
'
TRISC.4=1 ' input TASTER
TRISC.5=0 ' output LED1
ANSELA = 0 ' ADC off all
ANSELB = 0 '
ANSELC = 0 '
'
'************************************************* ******************************
''************************* DT_INTS-14 *****************************************
'
INCLUDE "DT_INTS-14_16F15345-A.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
'
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
'

T1CLK = 1; CS FOSC/4; 534mS




T1CON = $31 ; Prescaler = 8, TMR1ON
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
'


'*************************** PIN NAMES *****************************************
TASTER VAR portC.4 '
LED1 VAR portC.5
'
' test program for PIC16F15345 with DT_INTS-14
' when button pressed, display "LED-blinky"
' TMR1 interupts toggle LED1
start:
GOSUB clearLCD
LCDOUT $FE,$80," TEST 16F15345"
LCDOUT $FE,$94," 20250825"
LCDOUT $FE,$D4," push button"
'
WHILE TASTER = 1 : WEND ' wait for pressed taster
PAUSE 500
'
GOSUB clearLCD
LCDOUT $FE,$80," LED-blinky"
'
Main:
PAUSE 1
GOTO Main
'
'************************************************* ******************************
'
clearLCD:
LCDOUT $FE,$01
RETURN
'
'---------------------[TMR1 - interrupt handler]--------------------------------
ToggleLED1:
TOGGLE LED1
@ INT_RETURN

richard
- 31st August 2025, 07:32
found a 16f15313 in my junk box which is from the same family tree

changing pins to suit all works as expected


#CONFIG __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_OFF
__config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _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



OSCCON1 = $62;
OSCFRQ = %101 ' 16mhz
DEFINE OSC 16


'-------------------- I/O ------------------------------------------------------

TRISa.2=0 ' output LED1
ANSELA = 0 ' ADC off all


'************************************************* ******************************
''************************* DT_INTS-14 *****************************************
'
INCLUDE "DT_INTS-14_16F15345-A.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
'
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
'

T1CLK = 1; CS FOSC/4; 534mS
T1CON = $31 ; Prescaler = 8, TMR1ON


@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
'


'*************************** PIN NAMES *****************************************

LED1 VAR porta.2


' test program for PIC16F15313 with DT_INTS-14


' TMR1 interupts toggle LED1

'
Main:
PAUSE 10
GOTO Main
'
'************************************************* ******************************


'---------------------[TMR1 - interrupt handler]--------------------------------
ToggleLED1:
TOGGLE LED1 ; 534mS
@ INT_RETURN

dran11
- 31st August 2025, 21:50
Works.
Thank you teach...master .