EmbeddedRelated.com
Forums

Doubt on FIOPIN functionality

Started by dhan...@solus.co.in March 26, 2010
Hi to all,

I am facing a different problem with my hardware when i tried to work GPIO's. I am using LPC2388 and Keil3

I written a test code in that i have configured P0.23 to P0.26 as Inputs and P0.27, P0.28 as outputs
This is my piece of code


#define OP_BUZZ2_ON (FIO0CLR3 |= 0X08)
#define OP_BUZZ2_OFF (FIO0SET3 |= 0X08)
#define IP_DURESS_STATE ((FIO0PIN2 & 0X80)?OFF:ON)
#define IP_IR_SENSOR_BIO ((FIO0PIN3 & 0X01)?ON:OFF)
#define IP_TAMPER_STATE ((FIO0PIN3 & 0X02)?OFF:ON)
#define MASTER_RESET ((FIO0PIN3 & 0x04)?OFF:ON)

SCS |= 0x01; // High speed GPIO is enabled on ports 0 and 1
PINSEL10 &= 0xFFFFFFF7; // DISABLE ETM

PINSEL1 = 0xFC003FFF; // P0.23 to P0.28 as GPIO's

FIO0DIR2 = 0x3F; // P0.23 as Input
FIO0DIR3 = 0x18; // P0.24, P0.25, P0.26 as Inputs and P0.27, // P0.28 as Outputs

FIO0MASKU = 0xF87F;


And in my main code, I am checking each Pin status in two ways 1. Without debug 2.With debug

My while loop looks like below

if(IP_TAMPER_STATE)
Tamper_Status.Switch_Status = 1;
else
Tamper_Status.Switch_Status = 0;

if(!IP_IR_SENSOR_BIO) // Bio IR sensor check the status // If not pressed
{
Bio_Sensor_Stat.Bio_IR_Status = 0;
}
else
Bio_Sensor_Stat.Bio_IR_Status = 1; // Pressed

if(MASTER_RESET) // Master reset key pressed
{
System_Hard_Stat.Master_RST_Status = 1;
OP_BUZZ2_OFF;
}
else
{
System_Hard_Stat.Master_RST_Status = 0;
OP_BUZZ2_ON;
}


If i put in debug mode if i run it without stopping everything's are working fine. If i single step at this line if(MASTER_RESET), the FIO0DIR2, FIO0DIR3 values overwritten to 0xFF and 0x3F. So the voltage on those Pins get dropped to zero. Not only on That line and corresponding pin, all pins giving the same status and those Pin voltage derived to Zero. I am confused a lot on this. because of this my whole development process stopped.

Please anyone give me suggestion on this as soon as possible. Ask me if you need any additional details on this.

An Engineer's Guide to the LPC2100 Series

d...@solus.co.in wrote:
> #define OP_BUZZ2_ON (FIO0CLR3 |= 0X08)
> #define OP_BUZZ2_OFF (FIO0SET3 |= 0X08)

Those at least are wrong. Don't know whether it explains anything, though.

--

Timo

Hi to all,
>
>I am facing a different problem with my hardware when i tried to work GPIO's. I am using LPC2388 and Keil3
>
> I written a test code in that i have configured P0.23 to P0.26 as Inputs and P0.27, P0.28 as outputs
>This is my piece of code
>
>
>#define OP_BUZZ2_ON (FIO0CLR3 |= 0X08)
>#define OP_BUZZ2_OFF (FIO0SET3 |= 0X08)
>#define IP_DURESS_STATE ((FIO0PIN2 & 0X80)?OFF:ON)
>#define IP_IR_SENSOR_BIO ((FIO0PIN3 & 0X01)?ON:OFF)
>#define IP_TAMPER_STATE ((FIO0PIN3 & 0X02)?OFF:ON)
>#define MASTER_RESET ((FIO0PIN3 & 0x04)?OFF:ON)
>
>SCS |= 0x01; // High speed GPIO is enabled on ports 0 and 1
>PINSEL10 &= 0xFFFFFFF7; // DISABLE ETM
>
>PINSEL1 = 0xFC003FFF; // P0.23 to P0.28 as GPIO's
>
>FIO0DIR2 = 0x3F; // P0.23 as Input
>FIO0DIR3 = 0x18; // P0.24, P0.25, P0.26 as Inputs and P0.27, // P0.28 as Outputs
>
>FIO0MASKU = 0xF87F;
>
>
>And in my main code, I am checking each Pin status in two ways 1. Without debug 2.With debug
>
>My while loop looks like below
>
>if(IP_TAMPER_STATE)
> Tamper_Status.Switch_Status = 1;
>else
> Tamper_Status.Switch_Status = 0;
>
>if(!IP_IR_SENSOR_BIO) // Bio IR sensor check the status // If not pressed
>{
> Bio_Sensor_Stat.Bio_IR_Status = 0;
>}
>else
> Bio_Sensor_Stat.Bio_IR_Status = 1; // Pressed
>
>if(MASTER_RESET) // Master reset key pressed
>{
> System_Hard_Stat.Master_RST_Status = 1;
> OP_BUZZ2_OFF;
>}
>else
>{
> System_Hard_Stat.Master_RST_Status = 0;
> OP_BUZZ2_ON;
>}
>
>
>If i put in debug mode if i run it without stopping everything's are working fine. If i single step at this line if(MASTER_RESET), the FIO0DIR2, FIO0DIR3 values overwritten to 0xFF and 0x3F. So the voltage on those Pins get dropped to zero. Not only on That line and corresponding pin, all pins giving the same status and those Pin voltage derived to Zero. I am confused a lot on this. because of this my whole development process stopped.
>
> Please anyone give me suggestion on this as soon as possible. Ask me if you need any additional details on this.
>

No. i made it for some purpose. Those lines are Active low on peripherals.

I would like to say some more details tat
1. I doing this on my newly designed hardware where remaining GPIO's are working well with and without debug. Those GPIO's are taken from other Ports. Even from Port 0 p0.8 and P0.9 are working fine as GPIO.

2. I am facing problem with the Ethernet circuit too where i checked all possible hardware connection. and tried to write and read the Phy registers. I succeed on Reading and wring to the Phy registers. I would like to know what are the Debugging methods are mandatory to check a Phy IC whether its communicating with my Controller as well as to the network.

My speed LED is always high. When i connect RJ45 with my board no Link lED nor Ack LEDs are blinking. I would like to know what are the Ways available to debug my board?

My old version Board is working fine without any issue which i listed above.
Please suggest me solution for this. I am totally clueless on this....
d...@solus.co.in wrote:
> Hi to all,
>>
>> I am facing a different problem with my hardware when i tried to
>> work GPIO's. I am using LPC2388 and Keil3
...
>> Please anyone give me suggestion on this as soon as possible. Ask
>> me if you need any additional details on this.
>>
>
> No. i made it for some purpose. Those lines are Active low on
> peripherals.

What did you made "for some purpose"? You seem to be answering your own
question but your comment makes no sense. Or are you referring to my
post? Please, use then proper threading and don't write a new message
but use reply button instead and don't quote irrelevant parts from the
original post.

If you are referring to these lines:

#define OP_BUZZ2_ON (FIO0CLR3 |= 0X08)
#define OP_BUZZ2_OFF (FIO0SET3 |= 0X08)

it doesn't matter whether the signal is active low or not; I still think
you use those registers in a wrong way. Expression

FIO0SET3 |= 0x08

is the same as

FIO0SET3 = FIO0SET3 | 0x08

So what do you think you are actually writing into the register?

--

Timo

--- In l..., Timo wrote:

> If you are referring to these lines:
>
> #define OP_BUZZ2_ON (FIO0CLR3 |= 0X08)
> #define OP_BUZZ2_OFF (FIO0SET3 |= 0X08)
>
> it doesn't matter whether the signal is active low or not; I still think
> you use those registers in a wrong way. Expression
>
> FIO0SET3 |= 0x08
>
> is the same as
>
> FIO0SET3 = FIO0SET3 | 0x08
>
> So what do you think you are actually writing into the register?
>
> --
>
> Timo
>

This was pointed out earlier as well.

NEVER use |= or &= with a register named ...SET or ...CLR. If you want to set bit 4 do:

FIO0SET3 = 0x08;

If you want to clear bit 4 do:

FIO0CLR3 = 0x08;

You aren't writing to the ...PIN register, you are writing to a register that can only set or clear the bit/pin. But that register doesn't retain the value of the pins.

Richard

Also it is good to set PINSEL9-11 = 0;

2010/3/27 rtstofer

> --- In l... , Timo
> wrote:
>
> > If you are referring to these lines:
> >
> > #define OP_BUZZ2_ON (FIO0CLR3 |= 0X08)
> > #define OP_BUZZ2_OFF (FIO0SET3 |= 0X08)
> >
> > it doesn't matter whether the signal is active low or not; I still think
> > you use those registers in a wrong way. Expression
> >
> > FIO0SET3 |= 0x08
> >
> > is the same as
> >
> > FIO0SET3 = FIO0SET3 | 0x08
> >
> > So what do you think you are actually writing into the register?
> >
> > --
> >
> > Timo
> > This was pointed out earlier as well.
>
> NEVER use |= or &= with a register named ...SET or ...CLR. If you want to
> set bit 4 do:
>
> FIO0SET3 = 0x08;
>
> If you want to clear bit 4 do:
>
> FIO0CLR3 = 0x08;
>
> You aren't writing to the ...PIN register, you are writing to a register
> that can only set or clear the bit/pin. But that register doesn't retain the
> value of the pins.
>
> Richard
>
>
>
>#define OP_BUZZ2_ON (FIO0CLR3 |= 0X08)
>#define OP_BUZZ2_OFF (FIO0SET3 |= 0X08)
>
>it doesn't matter whether the signal is active low or not; I still think
>you use those registers in a wrong way. Expression
>
>FIO0SET3 |= 0x08
>
>is the same as
>
>FIO0SET3 = FIO0SET3 | 0x08
>
>So what do you think you are actually writing into the register?
>

I misunderstood your post. I got your point. I tried changing the line
#define OP_BUZZ2_ON (FIO0CLR3 = 0X08)
#define OP_BUZZ2_OFF (FIO0SET3 = 0X08)

But my problem still remains as it is. Whenever i tried to read the pins, the FIO0DIR2 and FIO0DIR3 values got changed to 0xFF, 0x3F.

>Also it is good to set PINSEL9-11 = 0;

I believe there is no PINSEL11 register available.

d...@solus.co.in wrote:
> But my problem still remains as it is. Whenever i tried to read the
> pins, the FIO0DIR2 and FIO0DIR3 values got changed to 0xFF, 0x3F.

Unfortunately, I have no idea on that. If I were you, I'd look if 32bit
(FIO0PIN, FIO0DIR...) versions of the registers worked in the same way. Also,
I'd check the header files that the registers are defined correctly there. And
when I have no further ideas, I usually resort to a general messing up.

--

Timo