View previous topic :: View next topic |
Author |
Message |
stma
Joined: 16 Feb 2004 Posts: 26
|
Shiftin on Port B |
Posted: Tue Mar 22, 2005 4:06 am |
|
|
Hi,
I was wondering if anyone clould take a look at this and give any idea where it is going wrong.
The pins are connected to a CPLD which is a 32 bit counter with a multiplexer controlled by the outputs of portA. The loop steps thru the various addresses of the multiplexer selecting which bit to put onto pin_b3.
Pin_b2 just enables the multiplexer.
I know the hardware works fine as I have had it running with PicBAsic Pro.
I am new to the shiftin command and suspect thats where the problem may lie.
#byte PORTA = 5
#define ALL_OUT 0
#define ALL_IN 0xff
#use fast_io(A)
void ReadScan()
{
int n,data;
int32 buffer;
set_tris_a(ALL_OUT);
output_low(pin_b2);
for(n=0;n<=31;n++)
{
porta=n;
output_high(pin_b2);
shift_left(&buffer,4,input(pin_B3));
output_low(pin_b2);
}
printf(" %08lx \n\r",buffer);
return;
}
Ive looked at pin_B2 and portA on the scope and they seems to be operating as required. Nothing coming in on B3 though.
Thanks
Steve |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Mar 22, 2005 7:36 am |
|
|
You should post a small but complete program and use the code button. As for the problem the code looks okay to me. My guess is that you are using a 16F87X device and didn't specify NOLVP in the fuses. RB3 is the LVP pin on these devices. |
|
|
Guest
|
|
Posted: Wed Mar 23, 2005 2:01 am |
|
|
All sorted. Thanks to all for the advice.
Cheers
Steve |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Mar 23, 2005 10:41 am |
|
|
So what was the problem? |
|
|
|