View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
PIN_A4 and PIN_B3 no output |
Posted: Fri Jun 25, 2004 8:40 am |
|
|
Hi Guys:
I wrote a program to blink all led (A, B, C, D, E port) in my easy2 board, all others was blinking except these two pins what might be wrong?
in output_high(PIN_A4);
delay_ms(20);
output_low(PIN_A4);
delay_ms(20);
output_high(PIN_B3);
delay_ms(20);
output_low(PIN_B3);
delay_ms(20);
or what might affect the output result? |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Jun 25, 2004 8:47 am |
|
|
When I push the RA4 reset button, RA4 did turn light on, and it did not affect other leds however, when I push the RB3 button, it turned on and program start running frm the beginning it works as a red reset button for all the leds. why? |
|
|
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
|
Posted: Fri Jun 25, 2004 9:51 am |
|
|
Depending on which PIC you use, the RA4 pin might be sink-only. So you have to wire your led to VCC, and sink through RA4 to ground.
<pre>
VCC ----|>------/\/\/\/\/------PIC's RA4
led resistor
</pre>
As for pin B3, depending on which PIC you use, it might be source-only. So you have to wire your led the other way around:
<pre>
GROUND ----<|------/\/\/\/\/------PIC's RB3
led resistor
</pre> |
|
|
Guest
|
|
Posted: Fri Jun 25, 2004 11:34 am |
|
|
Thank you laurent!
The PIC I am using is easy2 PIC16F877A. I did connected PIN_A4 with the circuit you provided, it works, however for the other one PIN_B3 it did not work. what do you think happened to Pin_B3 |
|
|
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
|
Posted: Fri Jun 25, 2004 11:37 am |
|
|
Might be many things... could you post your sample code? Maybe your port B isn't defined correctly, or something else uses it, or maybe it's defective. |
|
|
Guest
|
|
Posted: Fri Jun 25, 2004 11:45 am |
|
|
By the way, when I measure votages on these two bins, there is not signals changes anyway if I do not connect the circuits you provided.
when I push the reset button on PIN-B3, it did turns on.
my program is as simple as the code I just posted in my just post |
|
|
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
|
Posted: Fri Jun 25, 2004 11:47 am |
|
|
There must be something before that code. You should typically initialise your ports, set them as input/ouput or automatic, etc. If you're doing anything else, it might be interfering with your port later in your code and that might be the reason why it's not working properly.
As for the reset button, how is it connected to your circuit? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 25, 2004 1:06 pm |
|
|
Pin A4 and pin B3 are the two biggest "gotcha's" in the PIC world,
in terms of pin problems with the 16F87x series PICs.
This information is in the data sheet. You should read it.
Link to 16F877A data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf
Pin A4 is open-collector, and thus it can't put out a high level voltage.
Pin B3 is the PGM pin, and it comes from the manufacturer setup for
use with LVP mode (low voltage programming). You have to add
NOLVP to the #fuses statement in your CCS program, so that pin B3
can be used as a normal i/o pin. |
|
|
Guest
|
|
Posted: Fri Jun 25, 2004 2:02 pm |
|
|
hi laurent and PCM programmer:
Thank you for your help. The following is my whole programm, please help correct it. thanks again!
#if defined(__PCM__)
#include <16f877A.h>
#fuses HS,NOWDT,PUT
#use delay(clock=20000000)
#endif
#define PAUSE 200
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
//#device PIC16F877A
main()
{
while (TRUE) {
// printf("Port A/E Blink\n\r");
output_high(PIN_A0);
delay_ms(20);
output_low(PIN_A0);
delay_ms(20);
output_high(PIN_A1);
delay_ms(20);
output_low(PIN_A1);
delay_ms(20);
output_high(PIN_A2);
delay_ms(20);
output_low(PIN_A2);
delay_ms(20);
output_high(PIN_A3);
delay_ms(20);
output_low(PIN_A3);
delay_ms(20);
output_high(PIN_A4);
delay_ms(20);
output_low(PIN_A4);
delay_ms(20);
output_high(PIN_A5);
delay_ms(20);
output_low(PIN_A5);
delay_ms(20);
output_high(PIN_E0);
delay_ms(20);
output_low(PIN_E0);
delay_ms(20);
output_high(PIN_E1);
delay_ms(20);
output_low(PIN_E1);
delay_ms(20);
output_high(PIN_B0);
delay_ms(20);
output_low(PIN_B0);
delay_ms(20);
output_high(PIN_B1);
delay_ms(20);
output_low(PIN_B1);
delay_ms(20);
output_high(PIN_B2);
delay_ms(20);
output_low(PIN_B2);
delay_ms(20);
output_high(PIN_B3);
delay_ms(20);
output_low(PIN_B3);
delay_ms(20);
output_high(PIN_B4);
delay_ms(20);
output_low(PIN_B4);
delay_ms(20);
output_high(PIN_B5);
delay_ms(20);
output_low(PIN_B5);
delay_ms(20);
output_high(PIN_B6);
delay_ms(20);
output_low(PIN_B6);
delay_ms(20);
output_high(PIN_B7);
delay_ms(20);
output_low(PIN_B7);
delay_ms(20);}
} |
|
|
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
|
Posted: Mon Jun 28, 2004 6:44 am |
|
|
Could you explain how pin B3 is connected electrically? You talk about some RESET button that may be connected somewhere. Where is it connected?
I've been using 16Fxx chips without the NOLVP fuse and pin_b3 has always been accessible, so i don't think that this is the cause. You may try it though, just for kicks. |
|
|
|