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

PSoC™ 5, 3 & 1

AlVa_264671
Level 5
Level 5

Hi there

I'm trying to found a way to set the 3 DM bits of each pin belonging to 8 pin port 4 (in this case)  to set

all of them except one to HI- Z.

I have looked at TRM and CY boot component but according to my understanding that's is not possible with few line of code.

Any Help ?

0 Likes
1 Solution
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Gil is correct,

Look at the 5LP Register TRM: Chapter 1.3.232 PRT[0..11]_DM[0..2].

This requires that you set three registers with the bits either set or cleared.

If you know the DM values for each pin in the Port than it can be as simple as three byte writes.

For example:  Let's say ALL the pins of Port4 are set to DM = Strong to begin with.

At some point in your application, you to switch P4.7, P4.6, P4.5, P4.4, P4.2, P4.1 and P4.0 to Hi-Z but leave P4.3 to Strong.

You would write the following three lines of code:

PRT4_DM2 = b00001000;

PRT4_DM1 = b00001000;

PRT4_DM0 = b11110111;

You'll notice bit 3 of each DM register is different.  The DM[2:0] combination = Strong = b110.

The other bits use the DM[2:0] combination = Digital Input = b001.

However, if you need to only set specific bits of these DM registers and LEAVE the other(s) alone, it's a bit more complicated.  That will require a "read-modify-write" which takes a few more CPU cycles.

In that case, it might be quicker (and safer) to use the per-Pin API calls.

Len

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

View solution in original post

0 Likes
6 Replies
JOLO_264146
Level 4
First like received Welcome!
Level 4

Hi,

look for in "PSoC 5LP Registers TRM" document the registers PRT[0..11]_DM. In your case of Port4, PRT4_DM

in the case of port12, PRT12_DM and so on.

You have all info in "PSoC 5LP Architecture TRM" document, specifically at "I/O system". There is a table with a resume of all registers (19.2)

Regards

Gil

Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Gil is correct,

Look at the 5LP Register TRM: Chapter 1.3.232 PRT[0..11]_DM[0..2].

This requires that you set three registers with the bits either set or cleared.

If you know the DM values for each pin in the Port than it can be as simple as three byte writes.

For example:  Let's say ALL the pins of Port4 are set to DM = Strong to begin with.

At some point in your application, you to switch P4.7, P4.6, P4.5, P4.4, P4.2, P4.1 and P4.0 to Hi-Z but leave P4.3 to Strong.

You would write the following three lines of code:

PRT4_DM2 = b00001000;

PRT4_DM1 = b00001000;

PRT4_DM0 = b11110111;

You'll notice bit 3 of each DM register is different.  The DM[2:0] combination = Strong = b110.

The other bits use the DM[2:0] combination = Digital Input = b001.

However, if you need to only set specific bits of these DM registers and LEAVE the other(s) alone, it's a bit more complicated.  That will require a "read-modify-write" which takes a few more CPU cycles.

In that case, it might be quicker (and safer) to use the per-Pin API calls.

Len

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

Thank you Len.

This is pretty more clear to me.

Regards,

0 Likes
AlVa_264671
Level 5
Level 5

@

 

0 Likes
AlVa_264671
Level 5
Level 5

Hi,  Thanks for your answer

Do you mean to  write 8 statement like this,  where "y"

is the pin number?

This was copy from the TRM.

DM [ 2:0 ] = {PRT X .DM2 [ y ] ,PRT X .DM1 [ y ] ,PRT X .DM0 [ y ] }

Thank you.

0 Likes
Vison_Zhang
Moderator
Moderator 500 replies posted 100 sign-ins 250 replies posted
Moderator

I you want to config drive mode of 8 pins of a port simultaneously, using DMA to config the PRTxDM0/PRTDM1/PRTDM2 registers is a good way i think, because you can transfer 32 bit data parallel in phub and config all three registers simultaneously.

0 Likes