November 23, 2024, 02:52:06 AM

Mod-io2 GPIO3 and GPIO4 problems

Started by r.mcconnell, October 26, 2015, 12:18:00 PM

Previous topic - Next topic

r.mcconnell

Hi,
I'm working with the A20-olinuxino-micro and everything is going good, I started using the mod-io2 board and I have encountered a problem that is on appearing on the mod-io2 board even on one straight out of a box.  I test the board by using the ./modio2tool to control the gpio's and an led that I connect to GND and the gpio I'm testing.
These are the commands I run and the results: (these where ran on the brand new mod-io2 board)

root@a20-OLinuXino:~/MOD-IO2# ./modio2tool -B 2 -A 0x21 -T 0x00
root@a20-OLinuXino:~/MOD-IO2# ./modio2tool -B 2 -A 0x21 -p 01
done.
GPIO: 0x01
root@a20-OLinuXino:~/MOD-IO2# ./modio2tool -B 2 -A 0x21 -p 11
done.
GPIO: 0x03
root@a20-OLinuXino:~/MOD-IO2# ./modio2tool -B 2 -A 0x21 -p 21
done.
GPIO: 0x07
root@a20-OLinuXino:~/MOD-IO2# ./modio2tool -B 2 -A 0x21 -p 31
done.
GPIO: 0x07
root@a20-OLinuXino:~/MOD-IO2# ./modio2tool -B 2 -A 0x21 -p 41
done.
GPIO: 0x07
root@a20-OLinuXino:~/MOD-IO2# ./modio2tool -B 2 -A 0x21 -p 51
done.
GPIO: 0x27
root@a20-OLinuXino:~/MOD-IO2# ./modio2tool -B 2 -A 0x21 -p 61
done.
GPIO: 0x67

Problem 1: On pin 6 (gpio3) the led does not get lit which is shown by the GPIO: 0x07 result not changing.
Problem 2: On pin 7(gpio4) the led does get lit (even though the GPIO: 0x07 result not changing is still unchanged) but when I run the next command, it turns off.
I would really appreciate any help on fixing this so all gpio's can be used as outputs, and any ideas what is causing it.

Robert

henk57

Hi Robert.

GPIO3 is Input only (See READ.ME text file)
Furthermore, the GPIO are in BitMask.

   * SET_LAT(0x02):
      Set the output level of gpio. In the bitmask 1 corespond to logical
      "1", and 0 - logical "0". Again, GPIO3 can be only input, so the
      coresponding bit in the mask will be igrored.
   Example:
   --------
      START | ADDRESS | W | ACK | SET_LAT | ACK | VALUE | ACK | STOP
      
      where:
         ADDRESS = 0x21
         SET_LAT = 0x02
         VALUE = 0b0dddxddd   the bitmask, where bit0 is the value for
                        GPIO0, bit1 - GPIO1, etc. bit3 is
                        x - doesn't care.

And again you can read this also the READ.ME file.

r.mcconnell

Hi,

thanks for reply.
I think there is a lot more to it.  I have currently made changes to the firmware (MOD-IO2 firmware version 3.02 provide on MOD-IO2s page) and it appears to be working correctly.  When you look at the hardware connections documented in

https://www.olimex.com/Products/Modules/IO/MOD-IO2/resources/MOD-IO2.pdf

and the microchip PIC16(L)F1503

http://ww1.microchip.com/downloads/en/DeviceDoc/41607A.pdf

The firmware  shows in the CommandSetLat that GPIO3 is always input, but, the pins used by the mod-io2 ARE capable of both input and output, the firmware also shows in the CommandGetLat method that gpio4 is always input, when if it was consistent should be gpio3 (as you said); so it always reads gpio4 as being 0.  This is why when I run the command for ./modio2tool -B 2 -A 0x21 -p 41 it doesn't look like it has changed even though its turned on and when the next command is written it reads it in as 0, then when next command is writing out, it results in gpio4 being turned off.

Everything appears to be working as it should but if I am mistaken by what Olimex have done here, I am happily to be corrected.