[Oberon] PO2013 - Real time measurement

Paul Reed paulreed at paddedcell.com
Thu Apr 11 22:26:57 CEST 2019


> Reading the same pic I got..
> 
> :08000000200B01A008200086201F0AA0301006202F
...

Why in this second hex file are your byte counts 08H not 10H?

Note that the PIC program words are 14 bits, so padded up to 16 bits 
there are 8 words per line, not 8 bytes.

Still trying to get back on-topic, :) and in case it helps, below is my 
add-on routine to PICL.Mod to write hex files, including writing up to 
two config words as needed with my PIC16LF145x.

A simple example of usage, from an already-compiled PICL module, and 
where the config is all-ones, would be

   PICL.StoreHex -1 Test.hex

Cheers,
Paul


   PROCEDURE StoreHex*;
     VAR i, u, v, sum, conf: INTEGER;
       T: Texts.Text; S: Texts.Scanner;

     PROCEDURE nib(n: INTEGER);
     BEGIN n := n MOD 10H; IF n > 9 THEN INC(n, ORD("A")-ORD("9")-1) END;
       Texts.Write(W, CHR(n + ORD("0")))
     END nib;

     PROCEDURE byt(n: INTEGER; VAR sum: INTEGER);
     BEGIN nib(n DIV 10H); nib(n); sum := sum + n
     END byt;

   BEGIN conf := -1;
     Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); 
Texts.Scan(S);
     IF S.class = Texts.Int THEN conf := S.i; Texts.Scan(S) END;
     IF S.class = Texts.Name THEN
       Texts.WriteString(W, "PICL.StoreHex"); Texts.WriteHex(W, conf);
       Texts.Write(W, " "); Texts.WriteString(W, S.s);
       Texts.Append(Oberon.Log, W.buf);
       Texts.WriteString(W, ":020000040000FA"); Texts.WriteLn(W);
       FOR i := 0 TO pc-1 BY 8 DO
         Texts.Write(W, ":"); sum := 0; u := pc-i; IF u > 8 THEN u := 8 
END;
         byt(u*2, sum); (*nofbytes*)
         byt(i DIV 80H, sum); byt(i * 2, sum); (*byte address, 
big-endian*)
         byt(0, sum); (*record type - data*)
         FOR v := 0 TO u-1 DO
           byt(code[i+v], sum); byt(code[i+v] DIV 100H, sum)
         END;
         byt(-sum, sum); ASSERT(sum MOD 100H = 0);
         Texts.WriteLn(W)
       END ;
       IF conf # -1 THEN
         FOR i := 0 TO 2 DO (*config words: adr, conf1, conf2*)
           Texts.Write(W, ":"); sum := 0; byt(2, sum); (*nofbytes*)
           IF i = 0 THEN u := 0 ELSE u := 6+i END;
           byt(u DIV 80H, sum); byt(u*2, sum); (*byte address, 
big-endian*)
           IF i = 0 THEN byt(4, sum); (*record type - extended address*)
             byt(0, sum); byt(1, sum)
           ELSE byt(0, sum); (*record type - data*)
             IF i = 1 THEN u := conf DIV 10000H ELSE u := conf END;
             byt(u MOD 100H, sum); byt(u DIV 100H MOD 100H, sum)
           END;
           byt(-sum, sum); ASSERT(sum MOD 100H = 0);
           Texts.WriteLn(W)
         END
       END;
       Texts.WriteString(W, ":00000001FF"); Texts.WriteLn(W);
       NEW(T); Texts.Open(T, ""); Texts.Append(T, W.buf); Texts.Close(T, 
S.s);
       Texts.WriteInt(W, T.len, 5); Texts.WriteString(W, " done.");
       Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
     END
   END StoreHex;


More information about the Oberon mailing list