Home arrow Support arrow Forums

Luminary Micro Forums

westfw

Senior Boarder
Click here to see the profile of this user

2006/10/17 19:52

GPIO

Off elsewhere:
Capper wrote:
The "bit packing" in the GPIOPinWrite command took a while to figure out how to use also. I assumed if I wrote a 0 to a pin and it went low I could just write a 1 and it would go high - wrong...
You made me curious, so I took a look. Interesting; looks like GPIOPinWrite() is pretty much a straight implementation of the way the GPIO ports work (which is itself a bit unusual, I guess.) And I don't think you can write 0 to a pin and have it go low, either, can you? You still have to have the appropriate bit set in the ucPins argument.

The datasheet says this bit-selection scheme uses 256 "locations in the memory map"; I guess it means 256 longwords (1024 addresses, so to speak.)

You should be able to do
#define GPIOByteWrite(p, val) GPIOPinWrite(p, 255, val)if I'm understanding things correctly...

Does the GPIO pin masking feature interact with the "bit banding" generic feature in any useful way for accessing the pins individually?

Um, I feel like I'm asking about very basic ARM things here. On the other hand, I'm also thinking that the target audience of the Luminary chips (call them "People currently using 8bit microcontrollers") is likely to be wondering about the same issues. Is there already a "ARM for PIC/AVR users" guide somewhere that will provide a quick start? Or should I make that my contest entry :-)

login or register to reply

Capper

Expert Boarder
Click here to see the profile of this user

2006/10/18 07:20

Re:GPIO

And I don't think you can write 0 to a pin and have it go low, either, can you?

Actually, you can - since I was sending out a "0", I was actually sending out a "00000000" and the pin I was addressing went low as I expected.

GPIOPinWrite(GPIO_PORTA_BASE,0x20,0); //This works.

But when I tried to set the bit this way:

GPIOPinWrite(GPIO_PORTA_BASE,0x20,1); //Wrong.

I got nothing, since I assumed it was just a boolean parameter.

Until I figured out I had to do this:

GPIOPinWrite(GPIO_PORTA_BASE,0x20,0x20); or
GPIOPinWrite(GPIO_PORTA_BASE,0xff,0x20);

The latter also sets the rest of the port bits low however.

Capper

login or register to reply

westfw

Senior Boarder
Click here to see the profile of this user

2006/10/18 10:29

Re:GPIO

Ah. I assumed you were doing
GPIOPinWrite(GPIO_PORTA_BASE, 0, ~0x20)
or similar, which wouldn't do anything.

login or register to reply