Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Resource icon

Nigel Goodwin's tutorials in C 2012-01-11

I have decided to convert these tutorials into C. Mainly because there are hardware designs available.
The original designs and code are on Nigel's site..

Chip used in following tutorials "pic16f628a"
There is 9 tutorials in Lesson 1 (
There is 4 tutorials in Lesson 2 (
And 3 in lesson 3 (
Lesson 4 has only two (
Chip used in tutorial 6_7 is pic16f648a
Chip used in tutorial 7_7 and tutorial 8 is pic16f876a

I have finished and tested these tutorials and have tried to mimic the original ASM routines as best as I can, however due to slight language differences some parts MAY need explaining.

As soon as I complete a lesson I will upload the completed code.

I have written a basic explanation of the C components as it may be a little over some newbies heads.
( tutorial help.C )

The chip used is the same as the original tutorial ( Its mentioned in the asm code).
the compiler is Hi-tech lite v9.6 (shipped with MPLAB)

I have finished tutorial 5.. reading / writing IR using sony remote... But I need to get a ir transmitter and receiver
so once I've tested it I'll submit it.. OK I have checked this... Only two reading a remote... and being the remote.

It would be easy for someone to include an eeprom routine for the third example from Nigel..

There is now a little tutorial on the use of pointers that I have used in the tutorial remakes! Just to give an insight as
to why they are used.
( Pointers.c )

I've just finished the software I2C tutorial 1 but I need to re-read the originals as they appear to be VERY similar.

Nigel's tutorial 6 has 7 routines but for the purpose of C we really only need four.
I use 128k and 256k memory chips and writing to these chips are explained in the tutorials

tutorial 6_1 shows random access single byte addressing
tutorial 6_2 shows sequential access multiple byte addressing
tutorial 6_3 shows sequential access reading and writing the PCF8583 RTC.
tutorial 6_4 shows multiple eeprom access addressing single, multiple and strings.
I have gone the full hog and done tutorial 6_7 this is a data logger using the pcf8591 adc
and a smaller 24lc128 eeprom.
tutorial 7 1 through 6 are on the pic16f628a and are software serial routines output
to PC, LED's LCD etc...
tutorial 7_7 is on the pic16f876a, this is hardware serial PC and LCD output
I have kept the pic16f876a at 4mhz for this tutorial.

Tutorial 8 is hardware PWM on the pic16f876a.. There is only one tutorial.

Because C isn't as efficient as assembler the tutorial 6_7 will not fit onto a pic16f628a so
I had to upgrade to the slightly bigger pic16f648a.. As the tutorials from now on are written for
the pic16f876 you could use this board instead.

Tutorial 9 is on the pic16f628a and uses the hex key pad.
9_1 will display a keypress in hex and ascii on an lcd screen
9_2 will accept a 4 digit security code
9_3 is the same as 9_1 but output is via RS232 to a PC
9_4 is a IR transmitter but as its untested I will not upload it.

One file in tutorial 10... Dual seven segment display ( common anode )
This example uses interrupts on timer 2 to refresh the display.

Tutorial 11 is for ADC input on AN0 and AN1 using LCD and RS232 output
Tutorial 11.1 reads ADC channel 0 and displays the decimal and hexidecimal values
on the LCD
Tutorial 11.1a is the same as 11.1 but uses sprintf() to display hex values.
Tutorial 11.2 reads two ADC channels, 0 and 1 and displays on the LCD screen.
Tutorial 11.3 reads ADC channel 0 and displays as volts to 2 decimal places.
Tutorial 11.4 is the same as 11.3 but also outputs to a PC via RS232.

Tutorials 13 are based on the pic16f877a
Tutorial 13.1 Matrix of 8x8 led... inverting a square shape
Tutorial 13.2 Scrolling numbers 0 through 9.. left right up and down
Tutorial 13.3 Scrolling a text message **** NOTE **** the tutorial also includes
a file "fnt.c" This is the ASCII set in bitmap form (just include it in the build
in tutorial 13.3)

Tutorials 12 are based on the pic16f628a
Right!! Tutorial 12.... I have implemented Manchester encoding / decoding on basic serial
output... As I have never used this before (I use XRF & Xbee ) the transmitter and receiver
codes are included, just for an example... You will need to implement your own protocol.

Most RF device now have all the encoding / decoding done automatically

If anyone finds a BUG!!! please let me know... Also if there is something else that should be
in the tutorial.. I'll try and incorporate it...

It has since been drawn to my attention that referring to the register "OPTION" in my programs with the latest Hi-tech revisions throws up an error.... The newer compiler requires the OPTION register to be renamed OPTION_REG throughout the tutorials...

Thanks to "ClydeCrashKop" for this information...
    3.9 KB · Views: 9,220
    3.3 KB · Views: 4,740
    4 KB · Views: 4,780
    3.1 KB · Views: 4,269
  • tutorial help.c
    5.9 KB · Views: 4,354
  • Pointers.c
    3.2 KB · Views: 3,953
    16.7 KB · Views: 4,729
  • tutorial_8_1.c
    2.6 KB · Views: 4,199
    5.3 KB · Views: 4,387
  • tutorial 10.c
    1.5 KB · Views: 3,885
    7.5 KB · Views: 4,686
    3 KB · Views: 4,136
    4.7 KB · Views: 4,706
    4.2 KB · Views: 6,665
    8.4 KB · Views: 2,192

Latest threads

New Articles From Microcontroller Tips