Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

simple led program with pic 16f690 not working ???? please help

Status
Not open for further replies.

ami89

Newbie level 3
Joined
Jan 27, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
Hello all

I'm trying a simple LED blinking program on PORTA on PIC16F690 but it's not working, only one led is blinking RA0 ..
I'm using MikroC PRO the code:

void main()
{
TRISA = 0b000000;

while(1)
{ PORTA = 1;
Delay_ms(1000);
PORTA = 0;
Delay_ms(1000);
}
}

I tried it on a different port & it didn't work either

would appreciate any help you can offer :)
 

Try changing the value of PORTA
1 = LED 0
2 = LED 1
4 = LED 2
.....
7 = LED 0,1,2
.....

Code:
void main()
{   
    TRISA = 0b000000;
    
    while(1)
{ PORTA = 7;
   Delay_ms(1000);
   PORTA = 0;
   Delay_ms(1000);
}
}
 

Is it different from pic16f877a .. because it works fine with it ??
 

Does writing
Code:
PORTA = 1;
for 16F877A make all the LEDs connected to all 7 pins of PORTA blink?
It shouldn't. It should only blink RA0.
You know what, it shouldn't work at all. PORTA is multiplexed to ADC and comparator.
In 16F877A, you need to disable the analogue circuitry multiplexed to PORTA:
Code:
ADCON1 = 7;
CMCON = 7;
In 16F690, do:
Code:
ANSEL = 0;
ANSELH = 0;
CM1CON0 = 0;
CM2CON0 = 0;

Hope this helps.
Tahmid.
 

Thank you @hamed8419215 and @are .. it worked :)

@Tahmid .. yes it works well with 877a without turning the comparators/analog inputs off. I had a problem at the beginning but I added a 0.01 uF capacitor in parallel with the supply and it worked like magic :)

I have another question also regarding 16f690 .. now I'm trying to use a port as an input and display the output on PORTC

I wrote the following code:

Code:
unsigned char res;

void main()
{ 
TRISB= 0b11110000;
TRISC = 0x00;

while (1)
{ 
res = PORTB;
PORTC = res;
}

}

I tried it with PIC16f877a it worked fine .. but in 16f690 it is not, any clue, am I missing something??
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top