PDA

View Full Version : PIC16F18855 and DT elapsed timer



nomada
- 17th October 2018, 17:18
Hello to you all,

As PIC16F876A become obsolete I decided to use PIC16F18855 to replace it, it is much cheaper than the old PIC16F876A and has more features.

I implemented the code below (using PBP3) to get sure that the faithfull ELAPSED TIMER from Darrol's would still work with the new PIC

''* Name : test_pic16f18885.PBP *
'* Date : 17-10-2018 *
'* Version : 1.0 *
'* Notes : *
'************************************************* ***************
#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON ; pag 92
__config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF ;pag 93
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
__config _CONFIG4, _WRT_ON & _SCANE_available & _LVP_ON
__config _CONFIG5, _CP_ON & _CPD_OFF
#ENDCONFIG


DEFINE OSC 08

OSCFRQ = %11

include "DT_INTS-14.bas"
include "Elapsed_INT.bas"

Clear

ANSELA = 0
ANSELB = 0
ANSELC = 0

TRISA=%11111100
TRISB=%11111111
TRISC=%11111111

StatLED VAR PORTA.0
LED var PORTA.1

led =0

main:
led=1 ' to make sure PIC is running

pause 100
if SecondsChanged = 1 then
SecondsChanged = 0
Toggle StatLED ' counting seconds is "alive"
endif

led=1
pause 100

goto main


However the compilation always return:

[ASM ERROR] Symbol not previously defined (INT_ENTRY) (0) : ERROR[113)
[ASM ERROR] Symbol not previously defined (INT_ENTRY) (0) : ERROR[113)
[MESSAGE] pic16lf18855.pbpinc(603): HPWM command only supports CCP channels (not PWM channels).

Can any of you tell me how to solve this?

Thank's in advance

Vicente

HenrikOlsson
- 17th October 2018, 18:33
Several versions of ELAPSED_INT seems to exist. One that predates the existance of DT-Ints and one which is supposed to work WITH DT-Ints. For the one that's using DT-Ints it looks like you also need to include ReEnterPBP.bas file. Here's an example by Darrel himself, from this thread: (http://www.picbasic.co.uk/forum/showthread.php?t=19638&highlight=elapsed_int)


INCLUDE "DT_INTS-14.bas"
INCLUDE "ReEnterPBP.bas"
INCLUDE "Elapsed_INT.bas" ; Elapsed Timer Routines

ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ClockCount, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor

INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
ENDASM

GOSUB ResetTime ' Reset Time to 0d-00:00:00.00
GOSUB StartTimer ' Start the Elapsed Timer

Main:
IF SecondsChanged = 1 THEN
SecondsChanged = 0
LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
ENDIF
GOTO Main

Also, OSCFRQ = %11 can't be right but I suspect that it's the forum messing with the text.

When posting code, please use the proper code tags.

/Henrik.

sayzer
- 18th October 2018, 06:58
Henrik posted the same code 1 second before me. So I deleted mine. :)