Pic16f88

Status
Not open for further replies.

emkayPIC

New Member
Hi guys, I'm having real trouble getting this pic16f88 to work. I am new to this things. I have never worked with this model before but i have had little experience with pic16f877/a.
I wanted to test UART communication with pic16f88, but i didn't get any output. so, as i said, since i have never worked with pic16f88 before, i went to the basics and tried a simple LED blinking program. I wrote the following simple code on mikroC:

void main() {

ANSEL = 0;
TRISA = 0;
TRISB = 0;


do {
PORTA = 0x00;
PORTB = 0x00;

Delay_ms(1000);

PORTA = 0xFF;
PORTB = 0xFF;

Delay_ms(1000);
} while(1);
}

and programmed the pic using pickit 3. The program loads successfully onto the target device but the weird part is that when i connect an LED and a resistor(200 ohm) to any port, the LED stays on with a dim intensity(doesn't blink at all). I have checked and rechecked my circuit and i can't figure out my problem. I have connected pin 5 to ground, pin 14 to vdd and 11MHz oscillator with 22pf caps to pin 15 and 16. I have tried leaving MCLR to float and i have tried pulling it up to vdd by a 4.7k resistor, but still with no luck.

I took out the external oscillator and the LED stays on. so i guesed that there must be a problem with the oscillator so I tried using the internal oscillator of the PIC (but adding OSCCON = 0b01101000; above the line ANSEL = 0; ) with the necessary project property arrangement, and still no sign of luck. so please i any one has got a suggestion, help me out
 
Last edited:
I know nothing about mikroC but a search and look in suggested to me that perhaps your code is not right .
I have not seen the do..while statement used like you have it .
Looking for something similar gave this code
Code:
void main ()
{
        setup ();
        
        //Set time
        hr_h = 1;
        hr_l = 2;
        min_h = 3;
        min_l = 4;
        sec_h = 5;
        sec_l = 6;
        show_time ();
        setting_time = 1;
        set_time();
        while (1)
        {
                //blink_digit();
                if (tick)
                {
                        tick = 0;
                        show_time ();
                        Delay_ms (300);
                        Blink = 0;
                }
                check_bt ();
        }
}
 
The do - while loop is fine.....

The code should work.... I agree that the oscillator isn't being set correctly.... Look at the config words and tell me the hexadecimal number for A) external xtal and B) internal xtal

We should be able to see whats wrong...
 
Code looks fine to me. Did you change the oscillator speed on the left pane in MikroC? Not sure what the default is.

As its dimly lit, that suggests it is oscillating, don't know if you've tried connecting the LED from the PIN to VDD, and ground ? If its the same intensity in both configs then its 50% duty cycle and its oscillating way too fast. The compiler calculates the delay routines based on the figure you put in the project settings (in MHz with a decimal point!). I haven't worked with the'88 in a while but it was an oddball - the default setting for the internal osc was 32Khz (OSCCON = 0x00) - newer chips had the reset condition so that there were 1's in it, to make the default frequency of the intosc 4Mhz.

Add this line in your setup before the tris instructions:

OSCCON = 0x60;

That will tell the internal oscillator block to use the 4Mhz (internal osc divided by 2). Then set your clock in the project pane.

Alternatively... leave your code as stock and set your clock in the project pane to 0.032Mhz (32Khz) and it should flash at 1Hz.

Edit:

Ok, saw that you did the OSCCON thing, sorry. Maybe try changing the clock frquency setting in the project, until it blinks at the rate you intended (1Hz) ?
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…