1 Attachment(s)
Apparent 2k limit with 4k 16F88
Hi Folks,
Season's greetings to all.
I can't seem to compile without a huge list of errors (see attached) when exceeding the apparent
2k boundary of a 16F88 (4k chip). I edited to use a 16F1847 with no difference.
Can someone take a look at the error list and shed some light on what I may be doing wrong? I will send the code if it's needed.
I wish you all a safe 2021.
Regards,
Bill
Re: Apparent 2k limit with 4k 16F88
first thing i would try is in code and compile options make sure
generate coff is not ticked
Re: Apparent 2k limit with 4k 16F88
Hi Richard,
Thanks for your help - "Generate COFF" is not checked. The strange thing is the code compiles and runs as designed to the 2k limit, but when I add extra text (either via debug or on the LCD) or anything else that pushes the code over 2070 words, it lists all those errors.
My setup hasn't changed so I loaded an old 3k size program I wrote using the F88 and it compiles and runs fine. There is nothing flash about the problem code apart from using DT's Ints and a modified Inc file to run his Elapsed Timer code to 100ths precision, as I said, works well up to 2k only. I edited code and tried with Darrel's standard "Elapsed_INT.bas" and exactly the same result, compiles okay if less than 2071 words. PBP 3.0.10.4 and MPASM v5.71
Any suggestions?
Cheers,
Bill
Re: Apparent 2k limit with 4k 16F88
i don't see anything in the errors that indicates a code size problem .
i only have experienced those errors when using dt ints or similar with coff generation on or with duplicate includes
perhaps post your code for a more detailed examination
1 Attachment(s)
Re: Apparent 2k limit with 4k 16F88
Okay, here it is, note as is compiles but uncommenting the debug at line 318 pushes it over and it throws the errors.
See attached also...
Code:
'****************************************************************************************************
'* Name : Bubble rate V4-2.pbp #### NON Working Code #### *
'* : *
'* : 2070 words is the limit *
'* Date : 14/12/20 *
'* Device : 16F88 *
'* Version : 4-2 2053 words (PBP 3.0.10.4) *
'* : *
'****************************************************************************************************
' LCD PIC(F88) OTHER
'
' DB0-3 No connection
' DB4 PortA.0 (pin 17)
' DB5 PortA.1 (pin 18)
' DB6 PortA.2 (pin 1)
' DB7 PortA.3 (pin 2)
' RS PortA.4 (pin 3) 10K pullup to 5v due Open Drain.
' MCLR (pin 4) 10k pullup to 5v.
' RW Ground (pin 5)
' Vdd 5 volts (pin 14)
' Vss Ground (pin 5)
' Vo 20K potentiometer wiper (or ground).
' PortB.0 (pin6) Open collector output of sense head, series 1k.
' PortB.1 (pin7) + button (10k pullup to 5v).
' PortB.2 (pin 8) - button (10k pullup to 5v).
' CCP1 PortB.3 (pin 9) Serial in via 22k.
' PortB.4 (pin 10) Stepper coil 1 Or. Each coil 27R with common to Red via ULN2003 driver.
' PortB.5 (pin 11) Stepper coil 2 Ye.
' PortB.6 (pin 12) Stepper coil 3 Pk.
' PortB.7 (pin 13) Stepper coil 4 Bu.
' PortA.6 (pin 15) Serial out via 1k.
' E PortA.7 (pin 16) LCD.
'=========================================================================================================
' CONFIGURE DEVICE
'=========================================================================================================
#CONFIG ; F88 only
; __config _CONFIG1, _FOSC_INTOSCIO & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
__config _CONFIG1, _FOSC_INTOSCIO & _WDT_ON & _PWRTE_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
#ENDCONFIG
@ ERRORLEVEL -306 ; turn off crossing page boundary message
' -----[ Initialization ]------------------------------------------------------------------------------------------------
CMCON = 7 ' Comparators off, all digital.
TRISA = %00000000 '
TRISB = %00000111 ' Set I/O.
ANSEL = %00000000 ' All digital.
OSCCON = %01100010 ' 4Mhz (F88).
' OSCCON = %01110010 ' 8Mhz (F88).
Define OSC 4 ' Set Xtal Frequency
' Define LCD connections Change these to match your LCD
DEFINE LCD_DREG PORTA ' LCD Data Port
DEFINE LCD_DBIT 0 ' Starting Data Bit
DEFINE LCD_RSREG PORTA ' Register Select Port
DEFINE LCD_RSBIT 4 ' Register Select Bit
DEFINE LCD_EREG PORTA ' Enable Port
DEFINE LCD_EBIT 7 ' Enable Bit
DEFINE LCD_BITS 4 ' Data Bus Size
DEFINE LCD_LINES 2 ' Number of Lines on LCD
DEFINE DEBUG_REG PORTA ' Debug pin port
DEFINE DEBUG_BIT 6 ' Debug pin bit
DEFINE DEBUG_BAUD 9600 ' Debug baud rate
DEFINE DEBUG_MODE 1 ' Debug mode: 0 = True, 1 = Inverted
DEFINE DEBUGIN_REG PORTB ' Debug pin port
DEFINE DEBUGIN_BIT 3 ' Input pin.
DEFINE DEBUGIN_MODE 1 ' Debug mode: 0 = True, 1 = Inverted
'=========================================================================================================
' PIN ASSIGNMENTS, SYSTEM CONSTANTS, TEMPORARY VARIABLES
'=========================================================================================================
' Alias pins
ButReady var PortB.1 ' Take this pin low momentarily to Enable timing.
ButReset var PortB.2 ' Take this pin low momentarily to RESET all.
StepA var PORTB.4 ' Active high, input to ULN2003 driver.
StepB var PORTB.5 ' "
StepC var PORTB.6 ' "
StepD var PORTB.7 ' "
' Allocate variables
strAddr VAR BYTE ' Address of data.
char var byte ' Character sent to LCD or Serout.
bbl var BYTE ' Bubbles count.
Targetbpm var word ' Target Bubbles per Minute whole number.
bpm var word ' Bubbles per Minute whole number.
bpmi var BYTE ' Bubbles per Minute integer.
bpmr var BYTE ' Bubbles per Minute remainder.
Tally var word ' Total time between bubbles (2.22 secs @ 27bpm).
Tally2 var byte ' Counter for Av bpm.
Avgbpmt var word ' AVerage of bpm whole total.
Avgbpm var word ' AVerage of bpm whole.
Avgbpmi var word ' AVerage of bpm integer.
Avgbpmr var byte ' AVerage of bpm remainder.
degs var byte ' Degrees of stepper shaft to turn.
ReadyFlag var bit '
RunFlag var bit '
FinFlag var bit '
JumpFlag var bit ' If set then 10 samples taken, jump out.
'wsave VAR BYTE $70 SYSTEM ' alternate save location for W
' Stepper stuff
CounterA var word ' General Counter.
CounterB var word ' Counter for delays.
StepDelay var word ' Inter-Step Delay (uS).
StepReverse var bit ' 0 = Drive Forward, 1=Drive Reverse.
StepOut var byte ' A variable reflecting Stepper Channel Outputs.
StepOnLine var bit ' 0 = Stepper Off-Line (de-energised), 1 = Stepper On-Line (energised).
StepMode var Byte ' 0 = Single Drive A-B-C-D, 1=Two Phase Drive AB-BC-CD-DA, 2=Half-Step A-AB-B-BC-C-CD-D-DA.
StepStatus var byte ' Step Status (a value between 0 and 7) used internally by the StepDrive routine.
Include "MODEDEFS.BAS" ' Include Shiftin/out modes ### Don't know why this stops the compile!
INCLUDE "DT_INTS-14.bas" ' Needs to be assembled with MPASM **********
INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts
INCLUDE "Elapsed_INT_Ticks.bas" ; Elapsed Timer Routines *** edited for 1/100ths (Ticks).
' INCLUDE "Elapsed_INT.bas" ; Elapsed Timer Routines.
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _Bubble, PBP, yes
INT_Handler TMR1_INT, _ClockCount, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
pause 100 ' Let everything settle...
'latA.6 = 1 ' Prevent garbled serial - newer PICs.
PortA.6 = 1 ' Prevent garbled serial.
debug "I'm Alive",13,10
@ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts.
StepOnLine = 0 ' Power-Off Stepper.
Gosub StepDriveRAW ' Act on it.
StepStatus = 0 ' Preset initial Start Point.
StepMode = 0 ' Standard Phase Mode 0.
StepReverse = 0 ' Standard Forward Movement.
ReadyFlag = 0 ' Known state (not ready).
RunFlag = 0 ' Known state (not run).
FinFlag = 0 ' Not Finished.
JumpFlag = 0 ' Zero (Av loop not completed yet).
Targetbpm = 270 ' Whole number (actual 27.0 bpm) value of goal.
bpm = 0 ' Zero the bubble whole count.
bpmi = 0 ' Zero the bubble integer count.
bpmr = 0 ' Zero the bubble remainder count.
Avgbpmt = 0 ' Zero the Av. bpm total count.
Avgbpm = 0 ' Zero the Av. bpm whole count.
Avgbpmi = 0 ' Zero the Av. bpm integer count.
Avgbpmr = 0 ' Zero the Av. bpm remainder count.
Tally = 0 ' Zero the time.
Tally2 = 0 ' Zero the Av. count.
degs = 0 ' Zero the stepper degrees.
GOTO Satu ' Jump over the subroutines area.
'=========================================================================================================
' Subroutines here in the first page...
'=========================================================================================================
Line2:
LCDOut $FE,$C0," nf Go Rst" ' LCD line 2.
return
Reset:
GOSUB ResetTime ' RESET timer.
LCDOUT $FE,$80," " ' Erase LCD posn 1-13 line 1.
RunFlag = 0 ' Allow restart - has not run yet.
FinFlag = 0 ' Not Finished.
ButReady = 1 ' Enable the Ready button.
bbl = 0 ' Zero the bubble count.
bpm = 0 ' Zero the bpm whole count.
bpmi = 0 ' Zero the bubble integer count.
bpmr = 0 ' Zero the bubble remainder count.
Tally = 0 ' Zero the time between bubbles.
return
Timing: ' Displays the time like a clock, waits until SecondsChanged = 1, displays the time, then resets the flag.
IF TicksChanged = 1 THEN
if Seconds <= 10 then
LCDOUT $FE,2," ",DEC1 Seconds,".",dec2 Ticks ' Leading zero suppression. ############# " "
else
LCDOUT $FE,2,DEC2 Seconds,".",dec2 Ticks ' Only Secs, Hundredths.
endif
TicksChanged = 0
Endif
return
'Stepper Drive Subroutine
' From wherever the current step position happens to be this routine will drive Forwards or Backwards. If the Stepper
' happens to be parked in an illegal step for the current Mode, then it will ensure that the Stepper increments a
' one-half step first... this ensures that if the stepper is in position AB, and needs to increment TWO steps forwards
' in Mode 0, it increments AB-B-C rather than AB-C-D.
StepDrive: ' This section determines what the NEW StepStatus should be, depending on the Mode and Direction of step.
If StepReverse = 0 then
If StepMode = 0 then
Lookup StepStatus,[2,2,4,4,6,6,0,0],StepStatus
endif
endif
StepDriveRAW: ' All Stepper Coils low (disabled).
Low StepA
Low StepB
Low StepC
Low StepD
If StepOnLine = 1 then ' Energise Coils to New Settings.
' This Lookup table represents [A,AB,B,BC,C,CD,D,DA]
Lookup StepStatus,[1,3,2,6,4,12,8,9],StepOut
StepA = StepOut.0
StepB = StepOut.1
StepC = StepOut.2
StepD = StepOut.3
endif
Return
'=========================================================================================================
' Program area...
'=========================================================================================================
Satu: ' Operation when system first powered up.
GOSUB ResetTime ' Reset Time to 0d-00:00:00.00 (located in "Elapsed_INT.bas")
gosub Line2 ' Fill in lcd line 2 " nf Go Rst".
goto Running ' Jump.
' goto TestStepper ' Jump to stepper test code.
Running:
gosub Timing ' Displays time like a clock, waits until ?Changed = 1, displays the time, then resets the flag.
if RunFlag = 0 then ' Has not run yet.
if ButReady = 0 then ' Only run if Enable pushed.
pause 1000 ' Ensure not mid-bubble.
@ INT_ENABLE INT_INT ; Enable external (INT) interrupts.
endif
endif
' NOTE for some reason a For/Next loop causes weird problems so If/Endif used below marked ***.
if FinFlag = 1 then ' Has run.
RunFlag = 0 ' Enable.
@ INT_ENABLE INT_INT ; Enable external (INT) interrupts.
Tally = (Seconds*100)+Ticks ' Total time between bubbles e.g. 222 = 2.22 secs.
Tally2 = Tally2+1 ' Incr the Average counter.
if Tally2 = 10 then ' 10 samples. ***
JumpFlag = 1 ' Av loop completed, prepare to jump.
Avgbpmt = 0 ' Reset Av total count.
Avgbpm = 0 ' Reset Av whole count.
Avgbpmi = 0 ' Reset Av integer count.
Avgbpmr = 0 ' Reset Av remainder count.
LCDOUT $FE,$C0," " ' Clear count area.
endif '
bpm = (60000/Tally) ' Whole number e.g. 60000/222 = 270.
bpmi = bpm/10 ' Extract integer e.g. 60000/222 = 270/10 = 27
bpmr = bpm//10 ' Extract remainder. 0
Avgbpmt = Avgbpmt+bpm ' Total Av. whole.
Avgbpm = Avgbpmt/tally2 ' Extract Av. whole.
Avgbpmi = Avgbpm/10 ' Extract Av. integer.
Avgbpmr = Avgbpm//10 ' Extract Av. remainder.
@ INT_DISABLE TMR1_INT ; Disable Timer 1 Interrupts.
debug # tally2,", Avgbpmt ",# Avgbpmt,", Avgbpm ",# Avgbpm,", Avgbpmi ",# Avgbpmi,10,13
@ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts.
LCDOUT $FE,$88,dec2 bpmi,".",dec1 bpmr," bpm" ' Feedback. Tilde (~) is 126 but this lcd shows -> instead.
if tally2 < 10 then ' Single digits, leading zero blanking.
LCDOUT $FE,$C0," ",dec1 tally2'," ",dec2 Avgbpmi,".",dec1 Avgbpmr," Avg" ' Feedback.
else
LCDOUT $FE,$C0,dec2 tally2'," ",dec2 Avgbpmi,".",dec1 Avgbpmr," Avg" ' Feedback.
endif '
LCDOUT $FE,$C2," ",dec2 Avgbpmi,".",dec1 Avgbpmr," Avg" ' Feedback.
pause 5000 ' Enough time to read.
if JumpFlag = 1 then UseStepper ' Av loop completed, jump.
gosub reset ' Reset selected vars to run again.
gosub Timing ' Refresh clock time.
ButReady = 0 ' Psuedo Enable pushed.
pause 1000 ' Ensure not mid-bubble.
@ INT_ENABLE INT_INT ; Enable external (INT) interrupts.
endif
If ButReset = 0 then gosub reset' Run again.
goto Running ' Loop until button is pressed.
UseStepper: ' Run the valve adjuster.
' Speed and performance is dependent on the mass and inertia of the stepper and it's load. The Delays may require
' consideration to make the Ramp-Up/down more applicable to the hardware and environment.
StepOnLine = 1 ' Bring Stepper On-Line (0 = all Stepper Coils Disabled).
Gosub StepDriveRAW ' All Stepper Coils low (disabled).
LCDOut $FE,1 ' Clear and home display, Line 1.
Tally2 = 0 ' Reset sample count for next cycle.
'@ INT_DISABLE TMR1_INT ; Disable Timer 1 Interrupts.
debug " at Stepper area",10,13
'@ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts.
' Compare measured Average to target and jump to correct any variation.
Avgbpm = 280 ' ****** Test value ******
select case Avgbpm ' Whole number e.g. 270 (27.0 bpm).
case Targetbpm ' Target value.
pause 60000 ' Wait about 1 minute.
goto Running ' Repeat monitoring.
case is > Targetbpm ' Too fast, close valve.
degs = 2 ' Move only 2°.
goto CloseLoop ' - jump to close valve (CCW, Forward) stepper code.
case is < Targetbpm ' Too slow,
degs = 2 ' Move only 2°.
goto OpenLoop ' - jump to open valve (CW, Reverse) stepper code.
end select
' 'Forward' code sees motor shaft move CCW (looking at shaft, closes needle valve).
CloseLoop: ' Slow Ramp-Up Stepper, 1 step per 0.7° (360° = 512 steps).
LCDOut $FE,2,"Closing ",dec1 degs,$DF ' Line 1.
debug "Closing ",dec1 degs,$DF,10,13
For CounterA = 0 to 2 step 1 ' 3 steps ~ 2° (2.1°).
Gosub StepDrive
StepDelay = 65500-(CounterA*32)
PauseUS StepDelay
Next CounterA
' Gosub StepDriveRAW ' All Stepper Coils low (disabled).
pause 5000 ' Time to read
LCDOut $FE,2,"Resting " ' Line 1.
'debug " ",10,13 '
for CounterB = 0 to 999 ' 1000 iterations.
pause 6'00 ' Wait about 10 minutes to settle HS-23.
next '
goto Running ' Repeat monitoring.
'' Run at constant Speed of 200 rpm (or so) for 3 Seconds
' LCDOut $FE,2,"Hold 200rpm" ' Line 1.
' For CounterA = 0 to 2000
' Gosub StepDrive
' PauseUS 1500
' Next CounterA
' 'Reverse' code sees motor shaft move CW (looking at shaft, opens needle valve).
OpenLoop: ' Slow Ramp-Down Stepper
If StepReverse = 0 then ' Change direction.
StepReverse = 1 '
else
StepReverse = 0 ' To be sure.
endif
LCDOut $FE,2,"Opening ",dec1 degs,$DF ' Line 1.
debug "Opening ",dec1 degs,$DF,10,13
For CounterA = 2 to 0 step -1 ' 3 steps ~ 2° (2.1°).
Gosub StepDrive
StepDelay = 65500-(CounterA*32)
PauseUS StepDelay
Next CounterA
' Gosub StepDriveRAW ' All Stepper Coils low (disabled).
pause 5000 ' Time to read
LCDOut $FE,2,"Resting " ' Line 1.
debug "Resting ",10,13 '
for CounterB = 0 to 999 ' 1000 iterations.
pause 6'00 ' Wait about 10 minutes to settle HS-23.
next '
goto Running ' Repeat monitoring.
'---[INT - interrupt handler]---------------------------------------------------
Bubble: ' Bubble detected to get here.
if RunFlag = 0 then ' Has not run yet.
GOSUB StartTimer ' Start the Elapsed Timer.
RunFlag = 1 ' Has run.
ButReady = 1 ' Single shot, disabled.
bbl = bbl+1 ' Incr the count.
@ INT_RETURN
endif '
if RunFlag = 1 then ' Has run.
GOSUB StopTimer ' Stop the Elapsed Timer.
FinFlag = 1 ' Finished.
@ INT_DISABLE INT_INT ; Disable external (INT) interrupts.
@ INT_RETURN
endif
1 Attachment(s)
Re: Apparent 2k limit with 4k 16F88
compiles just fine, its only 2059 words by my system
Quote:
uncommenting the debug at line 318 pushes it over and it throws the errors.
can you be more specific , i don't see anything there to un comment
Re: Apparent 2k limit with 4k 16F88
if you mean
debug " ",10,13 '
then it still complies and size goes to 2077
Re: Apparent 2k limit with 4k 16F88
Yes, the commented line above " for CounterB = 0 to 999 ' 1000 iterations."
That's weird, I can't get past 2070 words.
Feel free to add a bunch of anything to blow the code size out and see if it still compiles. I certainly can't - which begs the question what is different on your machine?
Re: Apparent 2k limit with 4k 16F88
my dt-ints is in pristine condition
Re: Apparent 2k limit with 4k 16F88
Hi Richard,
Thanks for the hint, yes changing my DT int's to v1.1 from 1.0 did the trick. Frustrating thing about it was I'd downloaded it a looonng time ago and didn't overwrite the old version at the time...
It does show though the inadequacies of the error field - not a lot of help if you are not a guru.
All the best for the New Year and do your best to stay away from New South Welshmen.
Cheers,
Bill
Re: Apparent 2k limit with 4k 16F88
Quote:
Thanks for the hint, yes changing my DT int's to v1.1 from 1.0 did the trick. Frustrating thing about it was I'd downloaded it a looonng time ago and didn't overwrite the old version at the time...
hmmm
mine is , as i say pristine ...
'* Name : DT_INTS-14.bas *
'* Author : Darrel Taylor *
'* Version : 1.10 (8/13/2010) *
'* Date : OCT 13, 2009
Quote:
All the best for the New Year and do your best to stay away from New South Welshmen.
yes , the good sentiment is returned