Possibility to create custom functions for basic digital input reads and output pin writes in PSoC Creator 4.0 using C/Assembly language

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
NaJa_4363881
Level 3
Level 3
10 replies posted 10 questions asked 5 replies posted

Hello, 

I am using PSoC 4 device (CY8C4014LQI-422) for buffering few digital input signals to digital output pins. I am currently using available APIs: Pin_write() and Pin_Read() to assign logic levels. But to understand the delay involved in PSoC response times, I wanted to try writing custom functions for Pin writes and reads in C or Assembly language and program the target PSoC to test for faster response times.

It will be great if someone could review and advise me on the possibility to write custom Pin read and Write functions in  C using PSoC Creator 4.0 / in Assembly language.

Thanks and Regards,

Nandhini Jayapandian

0 Likes
4 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Nandhini,

Using the API calls are the "safest" way to access individual GPIO pins or full ports.  When I say "safe" I mean the APIs are designed to accurate access these resources across different PSoCs and if HW issues are later found.  The APIs provide consistent access without major code rewrites on your part.

There are occasions where the API has some extra 'C' call steps to be universal and provide some abstraction.  For example, a GPIO read or write call to a single pin will provide a SHIFT and MASK function to isolate the specific pin (bit) for the other pins (bits) on the same port.  If you don't need this, you can minimize the execution time.

The best way to learn where is going on is to examine the API call function itself.

Other ways to speed optimize

One speed optimization is to use the DMA.  One restriction is that the DMA works with a minimum of one byte.

Another optimization is to create a HW state machine.  For example most PSoC4s have UDBs that allow you to create LUTs (Look-Up-Tables).  With a well constructed LUT, you may be able to turn on GPIO outputs with one or two BUS_CLK cycles.

If you're willing to share your project with the forum, we might be able to make better (more targeted) recommendations.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Thank you very much for the detailed explanation Len. I am interested in implementing the UDB option.

As  I am new to development using UDB, I am currently going through few examples to understand it and I think this is what I had been looking for long to be able to meet the expected performance. Thanks again for your time and support!

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

NaJa,

What do you mean by " buffering few digital input signals to digital output pins"? Do you simply read port and write it to another port, or some intermediate steps are involved? How many digital pins are you buffering?

0 Likes

Hello,

Yes, you are correct, I am simply trying to read digital ports and write to a different port and with the APIs Pin_Write() and Pin_Read() and it takes few 1 - 5 ms.

Thanks and Regards,

Nandhini Jayapandian

0 Likes