Pic Lab, PIC18, Experiment #3, ADC

I was working on a small project where I needed to catch a certain button pressed event. Sounds simple initially, but I have 10 such buttons and it means that I need to have 10 IOs, or port expander, or make a digital matrix button handler (like 3×4 keypad) but these all variants are boring, I wanted something more interesting and make something like a DAC based on these buttons which will be digitazed by the built-in ADC in pic18f14k50. Thus, we will use a single port instead of 10, by cost of the more complicated code.

Let me start as usual – from reading of the datasheet.

Continue reading

Pic Lab, PIC16, Experiment #12, EEPROM

Goal: To write and read EEPROM

What we have: PIC16f628a and a simple devboard.

Microcontroller PIC16f628a has 128 bytes of EEPROM memory on board, not too much but we have what we have. Hi-tech PICC compiler has internal functions for work with EEPROM, but here I’m going to make some my personal functions.

Let’s look at the EECON1 register:

ee
from the mikroe resourse
Continue reading

Pic Lab, PIC16, Experiment #9, The timer2 module

The goal: the same as previous, to get the 1KHz pulse.

What do we have: PIC16f628a, the simple devboard + proteus.

For this particular uC the timer2 module is another 8bits timer, which has some peculiarities.

timer2, a picture borrowed from the mikroe resourse
Continue reading

Pic Lab, PIC16, Experiment #8, The timer1 module

The goal: to get 1 Hz pulses.

What do we have: PIC16f628a, a handmade devboard, and proteus

Continuing to learn pic microcontrollers, and the timer1 is the next module in our way. Usually, this is a 16bit timer, so it allows to have a larger time frame.

timer1 block diagram, pic16f628a datasheet
Continue reading