EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Basic I/O setup for RCM 3100

Started by mits September 6, 2011
Hi, everyone.

I am trying to setup Parallel Ports A and F of an RCM3100 as byte-wide input ports. I write their corresponding register's values with WrPortI() function. Afterwards, I check with RdPortI() and find out that only the Shadow's value was updated.

I tried applying a 3.6v input into any one of the pins of PA and PF, and only PF is correctly functioning as an input port. I verified this via RdPortI().

What could I be missing?

Here is my code so far:

void RCMInit(void)
{
WrPortI(SPCR, &SPCRShadow, 0x80);
WrPortI(PADR, &PADRShadow, 0x00);

WrPortI(PFDDR,&PFDDRShadow,0x00);
WrPortI(PFCR,&PFCRShadow,0x00);
WrPortI(PFFR,&PFFRShadow,0x00);
}

main()
{
RCMInit();

while(1)
{
costate
{

}
}
}

--- In r..., "mits" wrote:
>
> Hi, everyone.
>
> I am trying to setup Parallel Ports A and F of an RCM3100 as byte-wide input ports. I write their corresponding register's values with WrPortI() function. Afterwards, I check with RdPortI() and find out that only the Shadow's value was updated.
>
> I tried applying a 3.6v input into any one of the pins of PA and PF, and only PF is correctly functioning as an input port. I verified this via RdPortI().
>
> What could I be missing?
> Here is my code so far:
>
> void RCMInit(void)
> {
> WrPortI(SPCR, &SPCRShadow, 0x80);
> WrPortI(PADR, &PADRShadow, 0x00);
>
> WrPortI(PFDDR,&PFDDRShadow,0x00);
> WrPortI(PFCR,&PFCRShadow,0x00);
> WrPortI(PFFR,&PFFRShadow,0x00);
> }
>
> main()
> {
> RCMInit();
>
> while(1)
> {
> costate
> {
>
> }
> }
> }
>

Reread the manual section on how to set the SPCR to use PortA as input or output. Do the same for PortF PFDDR. You have both ports configured as inputs, so they work as inputs

On 9/6/2011 9:34 PM, mehiegl wrote:
> I am trying to setup Parallel Ports A and F of an RCM3100 as byte-wide input ports. I write their corresponding register's values with WrPortI() function. Afterwards, I check with RdPortI() and find out that only the Shadow's value was updated.

Most of the Rabbit chip registers are write-only, hence the need for
shadow registers to remember what was written.

Your code looked ok for setting up port A as an input.

Writing to a port sets its out put registers. Reading the port address
reads the state of the pins, not the output register.

--
------
Scott G. Henion, Consultant
Web site: http://SHDesigns.org
Rabbit libs: http://shdesigns.org/rabbit/
------

Thank you for your reply, Scott.

I'd like to clarify your third paragraph. Correct me if I'm wrong, but this is how I understood it:

Writing to PADR when it is setup as an input will set ONLY the output register (I assume this is a separate register and address). When I read PADR, I am getting the state of the pins (high or low).

Did I paraphrase it correctly?

>
> Most of the Rabbit chip registers are write-only, hence the need for
> shadow registers to remember what was written.
>
> Your code looked ok for setting up port A as an input.
>
> Writing to a port sets its out put registers. Reading the port address
> reads the state of the pins, not the output register.
>
> --
> ------
> Scott G. Henion, Consultant
> Web site: http://SHDesigns.org
> Rabbit libs: http://shdesigns.org/rabbit/
> ------
>

On 9/6/2011 10:50 PM, mits wrote:
> Thank you for your reply, Scott.
>
> I'd like to clarify your third paragraph. Correct me if I'm wrong, but this is how I understood it:
>
> Writing to PADR when it is setup as an input will set ONLY the output register (I assume this is a separate register and address). When I read PADR, I am getting the state of the pins (high or low).
>
> Did I paraphrase it correctly?

Yes, all the I/O ports are that way. If you have the poster that shows
all the I/O registers they are different colors to indicate if they are
write only, read only or read/write. Note: some read different than was
written.

--
------
Scott G. Henion, Consultant
Web site: http://SHDesigns.org
Rabbit libs: http://shdesigns.org/rabbit/
------


The 2024 Embedded Online Conference