Crossworks and GPIO..

I have been tinkering a bit with FreeRTOS and the FreeRTOS/uIP version. I figured out how to tell Crossworks where all the include fles are.

However, I am getting errors on:

  GPIO_IODIR |= 0xff << 16;                           // Data port to output

  GPIO_IOCLR = 0xf << 4;                              // Put address on bus
  GPIO_IOSET = addr << 4;
  
  GPIO_IOCLR = 0xff << 16;                            // Write low order byte to data bus
  GPIO_IOSET = data << 16;

The errors are showing undefined on GPIO_IOCLR and the other similar stuff shown above, I am working with an LPC-2148 Proto Board. I looked in the LPC2148 user manual and it shows different register names such as FIOPIN, FIODIR, FIOSET, and FIOCLR, but these don’t seem to be in any include file.

However I do see registers like FIO0DIR0, FIO0PIN0, FIO0SET0, and FIO0CLR0. Do I need to change all the GPIO_* names to the FIO0* names? Is there anything else I have to do to make this change work? Why aren’t the FIODIR, FIOPIN, etc names in the include files?

I also see register names like IO0DIR, IO0PIN, etc. Are these the equivalent of the GPIO_* registers? There are so many different registers for GPIOs that it’s hard to know which to use.

8-Dale

linuxguy:
I have been tinkering a bit with FreeRTOS and the FreeRTOS/uIP version. I figured out how to tell Crossworks where all the include fles are.

However, I am getting errors on:

  GPIO_IODIR |= 0xff << 16;                           // Data port to output

GPIO_IOCLR = 0xf << 4; // Put address on bus
GPIO_IOSET = addr << 4;

GPIO_IOCLR = 0xff << 16; // Write low order byte to data bus
GPIO_IOSET = data << 16;



The errors are showing undefined on GPIO_IOCLR and the other similar stuff shown above, I am working with an LPC-2148 Proto Board. I looked in the LPC2148 user manual and it shows different register names such as FIOPIN, FIODIR, FIOSET, and FIOCLR, but these don't seem to be in any include file.



However I do see registers like FIO0DIR0, FIO0PIN0, FIO0SET0, and FIO0CLR0. Do I need to change all the GPIO_* names to the FIO0* names? Is there anything else I have to do to make this change work? Why aren't the FIODIR, FIOPIN, etc names in the include files?



I also see register names like IO0DIR, IO0PIN, etc. Are these the equivalent of the GPIO_* registers? There are so many different registers for GPIOs that it's hard to know which to use.



8-Dale

The answer to those errors seem simple enough. The header file that defines the register addresses is just that, an address map, so the author can use any names for the registers, although most header file authors seem to stick pretty close to the LPC manuals. However, there is no guarantee that the author included every possible register. The solution is to either use the names in the header file you have for your code, or to write your own header file to use the naming convention that you choose to use. You can also edit the header file that you already have, to add any missing registers. you can verify what registers are actually being refered to by looking up the real physical addresses in the manual and comparing them to the addresses in the header file that you have, since the only function of the header file is to map a physical address to a name.

–Dave

dshuman:
The answer to those errors seem simple enough. The header file that defines the register addresses is just that, an address map, so the author can use any names for the registers, although most header file authors seem to stick pretty close to the LPC manuals. However, there is no guarantee that the author included every possible register.

I find this to be a bit odd for a project that has a Crossworks project file. I searched all the include files for Crossworks though, but never found the GPIO_* register names used in the file, so I changed them to IO0* names. I'll check the addresses when I am more awake to be sure the names are appropriate. :)

I know about register and address maps. I am working on one for the Renesas H8 and H8SX microcontrollers.

8-Dale

You may try the header file included in ChibiOS:

http://chibios.svn.sourceforge.net/view … iew=markup

It defines both single registers and register blocks as structures.

gdisirio:
You may try the header file included in ChibiOS:

http://chibios.svn.sourceforge.net/view … iew=markup

It defines both single registers and register blocks as structures.

I would be looking for a header file that uses the names in the docunentation for my MCU (LPC-2148). Yours does not fit that bill as far as I can tell. I think I will just stick with the naming used by the Crossworks header files for now. I don't want to create my own register mapping file right now. :)

8-Dale

Not sure what you mean. The I/O register names in the LPC2148 data sheet are: IO0PIN, IO0SET, IO0CLR, IO0DIR, IO1PIN, IO1SET, IO1CLR, IO1DIR. FIO0DIR, FIO0MASK, FIO0PIN, FIO0SET, FIO0CLR, FIO1DIR, FIO1MASK, FIO1PIN, FIO1SET, FIO1CLR.

I don’t see anywhere register names like GPIO_IODIR in the data sheet.

Anyway, no problem.

linuxguy:
I find this to be a bit odd for a project that has a Crossworks project file. I searched all the include files for Crossworks though, but never found the GPIO_* register names used in the file, so I changed them to IO0* names. I’ll check the addresses when I am more awake to be sure the names are appropriate. :slight_smile:

8-Dale

If you are having those problems with a project that came exclusively from Crossworks, it seems like you should be asking them what is going on? The problem that you described seems to usually happen when people try to mix and match code from different sources.

–Dave

gdisirio:
I don’t see anywhere register names like GPIO_IODIR in the data sheet.

This is what I am asking about. I am working with FreeRTOS v4.7.0 and it has GPIO_* names in the cs8900a.c file for the ethernet interface. These are what I changed to IO0DIR instead of GPIO_IODIR, etc. I am still not sure what they should be though, but the compiler likes IO0DIR, IO0CLR, IO0SET, and IO0PIN and they seem to be closest to what the GPIO_* names would be.

8-Dale