This is a small project to program a PIC12F519 device (8-pin package) to provide a simple control for pull-up / pull-down resistors on a board.
The PIC interfaces to an FPGA with 4 I/O lines. (The FPGA programming is separate and is not part of this project.) Two of these lines are defined as clock and data for the one-bit serial interface between the FPGA and the PIC, and the remaining two are reserved for future use and should be configured as inputs.
The PIC also has two output pins. When the PIC receives a valid data transmission from the FPGA, it will set one output pin to the new value and set the other output pin to the opposite value, then store the new value in its built-in flash.
On power-up, the two outputs are initially 00. PIC immediately loads the current value from flash and then sets its output pins accordingly.
The output values are always either 01 or 10. For protection, the two outputs can never be on at the same time. The PIC must implement an off before on / break before make function when updating its outputs. To switch between 01 and 10, first write 00, then write the new value.
Overview of PIC function sequence:
1. Power up
2. Load data bit from flash memory
3. Load data bit into register to drive output pins
4. Check if new data has been transmitted to PIC by FPGA
5. If not goto 4.
6. Load new data into output pin control register.
7. Save new data in flash memory.
8. Goto 4.