[Oberon] PO2013 - Real time measurement

Paul Reed paulreed at paddedcell.com
Fri Apr 12 16:41:14 CEST 2019


> Possibly ready for PICL now.

Below is my PICL attempt at your program, if I understood it correctly 
from your hex, I hope it helps.

Note that I added the dummy variables simply so that I could use Prof. 
Wirth's version of the compiler unchanged.

You may want to alter PICL.Mod so that dc is initialised to 20H instead 
of 12 in PROCEDURE PICL.Compile, then remove my extra variables; 
although it can be handy as it is, saving adding new pre-defined symbols 
to the compiler if you want to access those registers (or corresponding 
ones in other banks).

I have a version of the compiler which allows me to optionally declare 
the address of a variable because I have used several PICs.

It's interesting that the PIC16F818 is right in the middle between the 
simplicity of the PIC16C84/PIC16F84A, and the complexity of the 
PIC16LF145x which has 32 banks.  I made a few other experimental changes 
to the compiler to accommodate that - not happy with them yet though.

Cheers,
Paul


MODULE My;

{define PIC16F818 regs not in PIC16C84 (as a kludge) to move variables 
to
   general-purpose RAM, which has changed from address 0CH to 20H in 
PIC16F818}
INT PIR1, PIR2, TMR1L, TMR1H, T1CON, TMR2, T2CON, SSPBUF, SSPCON, 
CCPR1L,CCPR1H, CCP1CON;
INT reg18, reg19, reg1A, reg1B, reg1C, reg1D, ADRESH, ADCON0;

{now our variables}
INT count;

PROCEDURE SetupPorts;
BEGIN A := 0; B := 0;  {all low}
   !S.5; A := 0; B := 0; !~S.5  {TRISA, TRISB - all output}
END SetupPorts;

PROCEDURE DelayLoop(INT n);  {~5n cycles}
BEGIN REPEAT INC n; DEC n; DEC n UNTIL n = 0
END DelayLoop;

PROCEDURE DelayMs(INT n);
BEGIN WHILE n # 0 DO DelayLoop(248); DEC n END
END DelayMs;

PROCEDURE Delay1Sec;
BEGIN DelayMs(250); DelayMs(250); DelayMs(250); DelayMs(250)
END Delay1Sec;

BEGIN SetupPorts;
   REPEAT count := 0;
     REPEAT B := count; Delay1Sec; INC count UNTIL count.4
   END
END My.

Edit.Open My.Picl    PICL.Compile @    PICL.Decode


More information about the Oberon mailing list