EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Port D

Started by Steve Trigero October 6, 2008
Using RCM3000, DC 9.25. I want to use bit 2 of port D as an output.

Using this code produces no results. The bit never changes state,
it's always 0. Adding a pullup will pull it high, which suggests it's either
not being set as an output or I'm not writing to it correctly.
The pin is not connected to any hardware.

What am I missing?

BitWrPortI( PDDDR, &PDDDRShadow, 1, 2 ); // Set bit 2 as output
BitWrPortI( PDDCR, &PDDCRShadow, 0, 2 ); // Standard output
WrPortI( PDB2R, NULL, 1 );
Steve
What I've found so far is, this statement

WrPortI( PDB2R, NULL, 1 );

does not work.

But this statement does work

WrPortI( PDB2R, NULL, 0 );

I can reset bit 2 of port D but I can't set it using the bit command.
I've looked at the assembly language behind each and they are
identical with the exception of the data written, which is expected.

If I use BitWrPortI( PDDR, &PDDRShadow, x, 2), I can both set and reset
the bit.

The above is true for both DC 9.25 and DC 9.62 on an RCM3000 module.

If I change to the RCM3900, DC 9.25 won't compile so I can't use it.
DC 9.62 compiles, but using the exact same code, I can neither set nor
reset the bit using either function call.

This is my complete test program:

void main()
{
WrPortI( PDFR, &PDFRShadow, 0 );
WrPortI( PDCR, &PDCRShadow, 0 );
BitWrPortI( PDDDR, &PDDDRShadow, 1, 2 ); // Set bit 2 as output
BitWrPortI( PDDCR, &PDDCRShadow, 0, 2 ); // Standard output
BitWrPortI( PDDR, &PDDRShadow, 1, 2 );

while(1) {
BitWrPortI( PDDR, &PDDRShadow, 0, 2 );
WrPortI( PDB2R, NULL, 0 );

BitWrPortI( PDDR, &PDDRShadow, 1, 2 );
WrPortI( PDB2R, NULL, 1 );
}
}

And to remind you, bit 2 of port D is not connected to anything on my test board.
I'm driving air.

Is there something else I should be doing, some other setup that I'm neglecting?
Steve

----- Original Message ----
From: Steve Trigero
To: r...
Sent: Monday, October 6, 2008 1:19:20 PM
Subject: [rabbit-semi] Port D
Using RCM3000, DC 9.25. I want to use bit 2 of port D as an output.

Using this code produces no results. The bit never changes state,
it's always 0. Adding a pullup will pull it high, which suggests it's either
not being set as an output or I'm not writing to it correctly.
The pin is not connected to any hardware.

What am I missing?

BitWrPortI( PDDDR, &PDDDRShadow, 1, 2 ); // Set bit 2 as output
BitWrPortI( PDDCR, &PDDCRShadow, 0, 2 ); // Standard output
WrPortI( PDB2R, NULL, 1 );
Steve
Steve Trigero wrote:
> What I've found so far is, this statement
>
> WrPortI( PDB2R, NULL, 1 );
>
> does not work.
>
> But this statement does work
>
> WrPortI( PDB2R, NULL, 0 );
>
> I can reset bit 2 of port D but I can't set it using the bit command.
> I've looked at the assembly language behind each and they are
> identical with the exception of the data written, which is expected.
>
> If I use BitWrPortI( PDDR, &PDDRShadow, x, 2), I can both set and reset
> the bit.
>
> The above is true for both DC 9.25 and DC 9.62 on an RCM3000 module.
>
> If I change to the RCM3900, DC 9.25 won't compile so I can't use it.
> DC 9.62 compiles, but using the exact same code, I can neither set nor
> reset the bit using either function call.
>
> This is my complete test program:
>
> void main()
> {
> WrPortI( PDFR, &PDFRShadow, 0 );
> WrPortI( PDCR, &PDCRShadow, 0 );
> BitWrPortI( PDDDR, &PDDDRShadow, 1, 2 ); // Set bit 2 as output
> BitWrPortI( PDDCR, &PDDCRShadow, 0, 2 ); // Standard output
> BitWrPortI( PDDR, &PDDRShadow, 1, 2 );
>
> while(1) {
> BitWrPortI( PDDR, &PDDRShadow, 0, 2 );
> WrPortI( PDB2R, NULL, 0 );
>
> BitWrPortI( PDDR, &PDDRShadow, 1, 2 );
> WrPortI( PDB2R, NULL, 1 );
> }
> }
>
> And to remind you, bit 2 of port D is not connected to anything on my
> test board.
> I'm driving air.
>
> Is there something else I should be doing, some other setup that I'm
> neglecting?
>

try:

WrPortI( PDB2R, NULL, 4 );

to set bit 2. Could probably also be:

WrPortI( PDB2R, NULL, 0xff );

If I remember right, you have to write to the bit #n register and also
have the bit set in the value to write.

--
------
| Scott G. Henion| s...@shdesigns.org |
| Consultant | Stone Mountain, GA |
| SHDesigns http://www.shdesigns.org |
------
Rabbit libs: http://www.shdesigns.org/rabbit/
today's fortune
Fudd's First Law of Opposition:
Push something hard enough and it will fall over.
--- In r..., Steve Trigero wrote:
>
> What I've found so far is, this statement
>
> WrPortI( PDB2R, NULL, 1 );
>
> does not work.
>
> But this statement does work
>
> WrPortI( PDB2R, NULL, 0 );
>
> I can reset bit 2 of port D but I can't set it using the bit command.
> I've looked at the assembly language behind each and they are
> identical with the exception of the data written, which is expected.
>
> If I use BitWrPortI( PDDR, &PDDRShadow, x, 2), I can both set and reset
> the bit.
>
> The above is true for both DC 9.25 and DC 9.62 on an RCM3000 module.
>
> If I change to the RCM3900, DC 9.25 won't compile so I can't use it.
> DC 9.62 compiles, but using the exact same code, I can neither set nor
> reset the bit using either function call.
>
> This is my complete test program:
>
> void main()
> {
> WrPortI( PDFR, &PDFRShadow, 0 );
> WrPortI( PDCR, &PDCRShadow, 0 );
> BitWrPortI( PDDDR, &PDDDRShadow, 1, 2 ); // Set bit 2 as output
> BitWrPortI( PDDCR, &PDDCRShadow, 0, 2 ); // Standard output
> BitWrPortI( PDDR, &PDDRShadow, 1, 2 );
>
> while(1) {
> BitWrPortI( PDDR, &PDDRShadow, 0, 2 );
> WrPortI( PDB2R, NULL, 0 );
>
> BitWrPortI( PDDR, &PDDRShadow, 1, 2 );
> WrPortI( PDB2R, NULL, 1 );
> }
> }
>
> And to remind you, bit 2 of port D is not connected to anything on
my test board.
> I'm driving air.
>
> Is there something else I should be doing, some other setup that I'm
neglecting?
> Steve
> ----- Original Message ----
> From: Steve Trigero
> To: r...
> Sent: Monday, October 6, 2008 1:19:20 PM
> Subject: [rabbit-semi] Port D
> Using RCM3000, DC 9.25. I want to use bit 2 of port D as an output.
>
> Using this code produces no results. The bit never changes state,
> it's always 0. Adding a pullup will pull it high, which suggests
it's either
> not being set as an output or I'm not writing to it correctly.
> The pin is not connected to any hardware.
>
> What am I missing?
>
> BitWrPortI( PDDDR, &PDDDRShadow, 1, 2 ); // Set bit 2 as output
> BitWrPortI( PDDCR, &PDDCRShadow, 0, 2 ); // Standard output
> WrPortI( PDB2R, NULL, 1 );
> Steve
>

The bit registers work differently from the BitWrPortI(...) instruction.

Instead of passing a 1 or 0 you have to pass a 1 in the actual bit
position you wish to write. This is a bit of nonsense really, so I
never use the bit registers and prefer to use BitWrPortI instead,
which will take a 1 or 0.

-kenny


Memfault Beyond the Launch