2 Replies Latest reply on Dec 28, 2019 8:30 PM by BoTa_264741

    Reading 16 GPIO pins "atomically"

    RiTa_288331

      Using the PSOC6 Pioneer kit, it is interfaced with an external ADC (16 bit parallel output).

       

      I have the 16 GPIO pins configured, but they are spread across several ports of the Pioneer kit (ports 0, 1, and 5).

       

      When reading these 16 bits, is there a "fast read", or a way of reading all 16 GPIO pins at once, in order to save time?

        • 1. Re: Reading 16 GPIO pins "atomically"
          RiTa_288331

          Just a quick addition, here is my code to read the 16 pins, scattered across multiple ports:

          resultADC[i] = (Cy_GPIO_Read(P11_0_PORT, P11_0_NUM)) |

                              (Cy_GPIO_Read(P11_2_PORT, P11_2_NUM) << 1) |                                                      

                              (Cy_GPIO_Read(P7_0_PORT, P7_0_NUM) << 2) |                                                      

                              (Cy_GPIO_Read(P7_3_PORT, P7_3_NUM) << 3) |                   

                              (Cy_GPIO_Read(P7_4_PORT, P7_4_NUM) << 4) |                                                      

                              (Cy_GPIO_Read(P7_5_PORT, P7_5_NUM) << 5) |                                                    

                              (Cy_GPIO_Read(P7_6_PORT, P7_6_NUM) << 6) |                   

                              (Cy_GPIO_Read(P7_7_PORT, P7_7_NUM) << 7) |                                                      

                              (Cy_GPIO_Read(P8_7_PORT, P8_7_NUM) << 8) |                                                      

                              (Cy_GPIO_Read(P8_6_PORT, P8_6_NUM) << 9) |

                              (Cy_GPIO_Read(P8_5_PORT, P8_5_NUM) << 10) |                                  

                              (Cy_GPIO_Read(P8_4_PORT, P8_4_NUM) << 11) |                                  

                              (Cy_GPIO_Read(P8_3_PORT, P8_3_NUM) << 12) |

                              (Cy_GPIO_Read(P8_2_PORT, P8_2_NUM) << 13) |                                  

                              (Cy_GPIO_Read(P8_1_PORT, P8_1_NUM) << 14) |   

                              (Cy_GPIO_Read(P8_0_PORT, P8_0_NUM) << 15);

          • 2. Re: Reading 16 GPIO pins "atomically"
            BoTa_264741

            RiTa,

            There is related discussion re writing 16-bit value atomically to 2 Control registers in PSoC5. Same approach may work for PSoC6

            Can be expanded control register component to 16bit or 32bit? (That meaning is not to use two control register components.)

             

            32-bit parallel non-contiguous GPIO write technique

             

            /odissey1

            1 of 1 people found this helpful