What is the advantage of using Control Register instead of simply Pin_Write ? (PSoC 5lp)

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

cross mob
PeSe_1509996
Level 3
Level 3
25 replies posted 10 sign-ins 5 questions asked

What is the advantage of using Control Register to control a pin High / LOW state instead of simply Pin_Write ? (PSoC 5lp)

Thanks !

Peter

0 Likes
1 Solution

Peter,

As-is, using Control register will be faster. On the other side the pin can be written directly in a single clock as well, like

Testpin_DR = 1 << Testpin_SHIFT; 

Testpin_DR = 0 << Testpin_SHIFT;

You may check some old posts on that

Macros for bit band access?

/odissey1

View solution in original post

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

Peter,

In simple cases, like having a single pin, there is not much difference. Control Register can help when several  non-continuous pins must be written (e.g. from different ports).

/odissey1

0 Likes

Dear odissey1,

thanks for your lightning fast reply !

I'm using it for firmware controlled SPIM (SPI Master) Slave Select pin.

Background: I've used both simple Pin_Write () and ControlRegister = 0 / 1 in the past several times -but SPI is more time sensitive..

Is there any , e.g. speed advantage of ControlRegister over Pin_Write () in such a single pin / non bus pins situtation like SPIM SS pin toggling?

Thanks in advance,

Peter

0 Likes

Peter,

As-is, using Control register will be faster. On the other side the pin can be written directly in a single clock as well, like

Testpin_DR = 1 << Testpin_SHIFT; 

Testpin_DR = 0 << Testpin_SHIFT;

You may check some old posts on that

Macros for bit band access?

/odissey1

0 Likes