Hi, I am new to PIC programming with C language..
My program is simple, which is to set Port B as output, and make a LED connected on any of the Port B pins blink with an interval of 1 second.
-------------------------------------------------------------------------------------------------------------------------------------
#include <htc.h>
__CONFIG (0x3F32);
void delay(unsigned long x);
void main()
{
TRISB = 0x00;
PORTB = 0;
while(1)
{
PORTB = 0xFF;
delay(1000);
PORTB = 0x00;
delay(1000);
}
}
void delay(unsigned long x)
{
for(;x>0;x--);
}
------------------------------------------------------------------------------------------------------------------------------------
I am able to compile and write the HEX code into the PIC microcontroller, but I got output voltage of about 2.45V in all of the port B pins. Anyone have idea what is going wrong here?
I tried to use MikroC built-in delay library, Delay_ms(1000) and everything works fine. So I can be pretty sure there is no problem on my hardware connections. I am using Crystal Oscillator of 20MHz anyway.