[Oberon] PO2013 - Real time measurement
Paul Reed
paulreed at paddedcell.com
Sat Mar 30 23:08:29 CET 2019
Hi Tomas,
> Looking at a simplified PIC prog by NW, it feeds signals from
> std PC parallel port at 0..5V.
I assume Prof. Wirth originally used a PC-based Oberon system to do PIC
programming, but the PICL.Mod on his home page in the section "PICL: A
Programming Language for the Microcontroller PIC" assumes the PIC is
connected to the FPGA. He added the RISC5's general-purpose I/O port
with this in mind, I think.
I am not sure how he did the level conversion between 3.3V of the FPGA
and 5V. I am suggesting powering the PIC with 3.3V to avoid this
problem.
Anyway, in https://inf.ethz.ch/personal/wirth/PICL/Sources/PICL.Mod.txt,
procedure Reset(), he sets all gpio output registers to 0, and then sets
the GPIO control bits 0 and 1 to set these pins to output.
In procedure bits(), he sends serial data to the PIC, least significant
bit first, by setting the data bit value on GPIO bit 0 (connected to PIC
RB7), and then toggling the clock on bit 1 (connected to PIC RB6).
Wirth's PICL.Mod code does not control the programming voltage on the
MCLR pin of the PIC - I assume he did this with a manual switch.
But you could use GPIO bits 2 and 3 (setting them also to output) to
control MCLR and RB3 on the PIC16F81x and set these according to the
low-voltage programming entry sequence in section 2.4.1 on page 5 of the
PIC16F818/819 Flash Memory Programming Specification:
http://ww1.microchip.com/downloads/en/DeviceDoc/39603c.pdf
This would also mean that you could reset the PIC from the FPGA, by
toggling MCLR low. You should still include a pull-up resistor on MCLR,
and a pull-down resistor on RB3, so that these pins don't float when the
FPGA GPIO pins are set to input (or switched off). The decoupling
capacitor between Vdd and ground is always a good idea too.
You could also output a toggling value on another pin, say GPIO bit 4,
and wire it to PIC RA7 (CLKI) to provide a clock to the PIC, for
experimentation and testing - but a free-running clock is much better
provided by a crystal and some capacitors (as shown in your diagram) or
a 3.3V crystal oscillator (the output of which is simply wired to CLKI).
Or if you want to be really cheap you can use the internal RC
oscillator (not very accurate).
You will have to understand how to program the configuration bits of the
PIC in order to select the appropriate oscillator (and do other things
like disable the watchdog timer, if you don't want to use it).
> Exception `MCLR' pin, which is driven 0/5/12V, not sure this is also
> applicable to newer PICs. Also not clear how to make 12V out of 5V.
The PIC programmers based on the old RS232 ports were able to do this
because 0 and 1 were represented by about -12V and 12V, respectively
(actually, anywhere between -3V and -25V, and anywhere between 3V and
25V). Scary. But they were able to regulate to the required voltages
using voltage regulators or Zener diodes.
I totally don't recommend doing this. Just to be clear. :)
> Low voltage may support programming in VDD operating range i.e. 2.0 to
> 5.5V (PIC16F8x), and requires `RB3' be pulled down by a resistor to
> GND.
> So one more wire in addition to [MCLR]
Right.
> Exception seems `MCLR' to do bulk erase, VDD of 4.5V to 5.5V is
> required!
Actually it says that the three bulk erase commands need the whole chip
to be powered at 4.5V-5.5V. But you only need these if you use the code
protection features. (And by the way Wirth's code has some occasional
strange sequences which are also related to code protection).
I would avoid code protection, but you could always build a special 5V
programmer using a PIC, and then take the PIC out of the circuit and
program it using your FPGA at 3.3V. Unless you want it code-protected.
;-)
HTH
Paul
More information about the Oberon
mailing list