Micro-controller Programming
MAS.863 -- Fall 2003

Notice

Assignment

Coding

Burning

Serial Transmission

Sample Codes

Applications

Resources

PIC Micro-Controller Sample Codes:

If you have some code to share with the class as samples of a call, function, action, algorhythm, programming style, utility, header, etc... Please email it to me (along with a brief description of what it does and what it needs/depends on) and I will post it on the site. Once we get through the Micro-Controller assignment, I hope to also put up everyone's codes.

Sample Codes:

delay-routine - Ben Buchwald a little routine to delay for some number of milliseconds. I thought other people might want to use it. The code is below. Before calling this routine, set W to the number of milliseconds you want to delay.
 fab.media.mit.edu/~zi201/sample.c  Zeynep's simple sample file for CCS PIC C- does RS232 and turns on/off LEDs
writei2c.c & readi2c.c - Dave

i2c communication between a PIC and an EEPROM

Here are a couple of sample files that demonstrates the "i2c" communication between a PIC and EEPROM. The idea behind i2c communication is that a byte is sent over one pin (each bit in succesion in time) rather than over 8 pins at the same time (one for each bit). This makes components smaller and layout easier.

(writei2c.c)
The PIC increments addresses from 0 to 255 and burns a value of 0 to 255 corresponding to each address on the EEPROM.

(readi2c.c)
The PIC increments address from 0 to 255 and reads the data back from the EEPROM corresponding ot each address. It outputs the data from the EEPROM to port B on the PIC (8 pins).

-Dave

snd.c, rcva.c & rcvb.c i2c communication between 3 PICs - this sample changes the PWM output of each PIC via i2c.
   
   

Check out these sites:

http://academic1.bellevue.edu/robots/pic1.html

Be sure to review the example files that come with whatever compiler you are using. They are quite helpful.