That board that's in the video is a LPC demo board the leds are on PORTC Do YOU GET that
IT's BLINKING DO YOU GET THAT the chip has just 3 PORTS PORTA PORTB PORTC
IT has ADC on PORTC
I don't need a hex I never had any broking blinky hex my blinky blinks fine
RA4 can sink only on the 16f877A DO YOU GET THAT in the data sheet maybe you missed that to.
RA4/T0CKI
pin is a Schmitt Trigger input and an open-drain output.
now, going to back to the comments about incorrectly configuring the port. here is a quick run that blinks the LEDs on Port A configured as analog input.
Code:
#include <htc.h>
//hardware configuration
#define LED PORTA
//end hardware configuration
//configuration bits
__CONFIG( XT & WDTDIS & PWRTDIS & BORDIS & LVPDIS & WRTEN & DEBUGDIS & UNPROTECT );
void init_mcu(void);
void delay(int dly);
void init_mcu(void) {
//up on power-on, porta set to analog input.
// ADCON1=0x06; //turn off adc;
TRISA=0b00000000; //set all pins on port C as output.
}
void delay(int dly) {
for(;dly>0; dly--)
;
}
void
main(void)
{
init_mcu();
LED=0b10101010;
while (1){
delay(500);
LED=0b01010101;
delay(500);
LED=0b10101010;
//TODO Auto-generated main function
}
}
as you can see, because analog pins are read as zero, LED=~LED; does not work anymore. But that's not the fault of the code, it is the fault of the programmer not reading the datasheet, not understanding the datasheet and failing to set up the port correct (analog vs digital).
this has nothing to do with multiplexing but has everything to do with incompetent programmer.
Attachments
16f877a flashing - incorrect port configuration.PNG
He had the setting for it right if you look at his code you can see that he set it right
Now he didn't post what he changed for the osc but if you read he said after he change
the osc setting it worked.
here you some thing to try in you sim
Code:
main(void)
{
unsigned char i, j;
TRISB = 0; /* all bits output */
j = 0;
for(;;) {
PORTB = 0x00; /* turn all on */
for(i = 100 ; --i ;)
continue;
PORTB = ~j; /* output value of j */
for(i = 100 ; --i ;)
continue;
if(BUTTON == 0) /* if switch pressed, increment */
j++;
}
}
He had the setting for it right if you look at his code you can see that he set it right
Now he didn't post what he changed for the osc but if you read he said after he change
the osc setting it worked.
I never used these header files.
All my ports blink, except some PWM ports. My configuration Bits are not set by code.
Also this command CMCON = 0x07 ; // Disable analog comparators didn't work for me, I made it a comment and managed to build it. But it works again regarding the leds.
Could you please recommend any good site with tutorials about step by step programming in HITECH C for PICs? How did you write this code? Please give me some hints !
Hi, you may check if _CONFIG works for you. For example, in my case, I should write PROG_CONFIG to be able to run. Additionally, you should prefer to set the Configuration bits from the menu, and not by code. This way is easier and you minimize the chance of having mistake. To begin, try to set the first (OSCILLATOR ) to HS if you use a >=4 MHz oscilator. The last ones should be not protected. I don't remember the rest right now, I have to check my pc. Let us know if you are ok and it works or anyway.