2 Replies Latest reply on Jul 21, 2015 1:42 AM by user_512410720

    Use I/O pins as an 8 bit wide port

    user_512410720

      Hi

         

      I'm migrating a design from the EZ-USB FX2LP microcontroller to the EZ-USB-FX3. Previously, I used the I/O pins to control a slow peripheral (2 x 16 character LCD panel with an 8 bit data bus).

         

      This used to be easy - I just wrote the value I wanted on the LCD data bus to one of the I/O port registers (e.g. IOC = 0x42) and then used a couple of other I/O lines to clock the data in.

         

      This all worked fine and I wanted to do the same with the new device. Unfortunately, the I/O lines in the EZ-USB-FX3 are not grouped into separate 8 bit ports  - they are all treated individually.

         

      Can anyone tell me how I would write a single 8 bit byte to 8 of the I/O lines without having to write each bit individually? I'm just looking for a simple solution to this (I'd prefer not to have to do this through GPIF II as this seems like a lot of work just to set 8 I/O pins at the same time).

         

       

         

      Thanks in advance

        • 1. Re: Use I/O pins as an 8 bit wide port
          Madhu Lakshmipathy

          Hi,

             

          It is true that in FX3, IO Pins are not grouped. So you have to write the values individually to the GPIOs. However you can reduce the time delay between writing to one GPIO and another, by writing directly using the registers instead of APIs. By this, even though you write individually one by one, as this operation is very fast, it would appear that all the 8 GPIOs are written at the same time.

             

          You can write to a GPIO by setting the b0 Bit (LSB) of the GPIO_SIMPLE register  as 1 or 0 using the firmware. There are 61 GPIO_SIMPLE registers. The base address is 0xE0001100 . The address of each is calculated as GPIO_SIMPLE(x) = 0xE0001100 + (x*0x4). Hence GPIO_SIMPLE(0) is at address 0xE0001100, GPIO_SIMPLE(1) is at address 0xE0001100 + 0x4 and so on. The definition of each of these is the same. (Refer section 10.22.1 in FX3 TRM).

             

          For example to set GPIO[2] as 1:

             

          The address is 0xE0001100 + 2 * 0x04 = 0xE0001108

             

          To set the MSB of this as 1, 

             

          *(uint32 *)(0xE0001108) |= 1;

             

          Similarly, you can do for 7 other GPIOs.

             

          Regards,

             

          - Madhu Sudhan

          • 2. Re: Use I/O pins as an 8 bit wide port
            user_512410720

            Thanks Madhu

               

            That makes sense. Thanks for your help.

            • 3. Re: Use I/O pins as an 8 bit wide port
              user_512410720

              Hi Madhu

                 

              One more question if I may. The example you supplied shows a fast way to write to the I/O pins using direct addressing. Would you be able to help me to read data quickly from a simple I/O port using direct addressing too?

                 

              Thanks in advance.