EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

MX31 GPIO

Started by Dread_Locks April 4, 2007
Hello,

I'm new to linux and I have MX31ADS board from freescale. I need to
read and write to some GPIO ports    and I was wondering how to do it.

I dont even know which pins on the MX31 chip are available to use, how
to set the port direction, or read  and write to the ports from a
linux C program.

Does any body know where I can get some information on how to do it?
maybe some sample source code in C would be wonderful.

Thanks
Dread_Locks

Dread_Locks wrote:
> Hello, > > I'm new to linux and I have MX31ADS board from freescale. I need to > read and write to some GPIO ports and I was wondering how to do it. > > I dont even know which pins on the MX31 chip are available to use, how > to set the port direction, or read and write to the ports from a > linux C program. > > Does any body know where I can get some information on how to do it? > maybe some sample source code in C would be wonderful. > > Thanks > Dread_Locks >
If you are to do this right, then you need to become fully familiar with the internal architecture of the beast. You need a copy of the cpu programming manual, which you should have somewhere amongst all the accompanying docs / software. Look up the chapter on ports and find out how to set or clear a bit, then find the main cpu device header file, which defines all the hardware addresses, system registers and various bits symbolically. Find out from the hardware schematic and existing port usage which port pins are available. When you have all this info, you may be ready to write a driver for the port, if one doesn't already exist. The important thing to stress is that it really isn't a 5 minute task. You need to have a full understanding because (for example) device pins are often shared between peripherals and may interact in non obvious ways. In summary, expect to spend a couple of weeks at least getting up to speed. One of the best ways to become familiar with any new processor is to write a set of drivers / bsp (board support package) for all the major on board peripherals. It can seem like a lot of work, but is a good investment as it only needs to be done once. You then have the knowledge and driver code for every project where you use the cpu... Chris -- ---------------------- Greenfield Designs Ltd Electronic and Embedded System Design Oxford, England (44) 1865 750 681
On 4 Apr 2007 08:50:44 -0700, "Dread_Locks" <nsmith@islandlogix.com>
wrote:

>Hello, > >I'm new to linux and I have MX31ADS board from freescale. I need to >read and write to some GPIO ports and I was wondering how to do it. > >I dont even know which pins on the MX31 chip are available to use, how >to set the port direction, or read and write to the ports from a >linux C program. > >Does any body know where I can get some information on how to do it? >maybe some sample source code in C would be wonderful.
AS root you should be able write directly to the hardware from your program. Once you have sorted out which registers to use, you can write a device driver through which a normal user space program can access the specific hardware. The book "Linux Device Drivers" is available at http://www.oreilly.com/catalog/linuxdrive2/chapter/book Regards Anton Erasmus

The 2024 Embedded Online Conference