- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Tags:
- device programming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Len.
This is pretty more clear to me.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@VisonZ_71 and Gil
Thank you both of you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.