Tuesday, July 29, 2008

Note for PIC16F887

From now on, my projects will be using PIC16F887 as the default microcontroller. As it is cheaper than the PIC16F877A and of course, it's newer.
Here, I'd like to document some configurations of the PIC16F887 for simple projects that don't relate to A/D conversion: (I'm no expert but the settings here are working for me)
- ANSEL = 0x00; // Make Digital I/O for PORTA (default is analog I/O), this is a must for input buttons, keys or whatever digital input/output
- ANSELH = 0x00; // Make Digital I/O for PORTB, this is a must otherwise the behavior of the ports will be unexpectable
- OSCCON = 0x75; // 8MHz Internal Oscillator , consumes more power
Or
- OSCCON = 0x65; // 4MHz Internal Oscillator , consumes less power

Timer1 Module Settings
- T1CON = 0x8F; // TMR1 Prescaler 1:1 external clock
- INTCON = 0xC0; // Set GIE, PEIE
- TMR1H = 0x80;
- TMR1L = 0x00;
- Delay_ms(10); // Delay for setting up TMR1
- PIE1.TMR1IE = 1; // enable interupt

Note: Microcontroller Devices are very sensitive to noise. Ground Plane and Noise Decoupling capacitor at power source may be needed.

1 comment:

anthony said...

Hello there!
Can you make a thermometer system
with the use of an LM35 + PIC16f877A
with a Mikco C code used then the output is displayed on a 7 segment display.
Thanks and i've learned a lot from your site.