- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have 8 digital outputs that are on various pins of the 5LP that I want to control as a port using an 8-bit variable in code.
I created a digital output pin then then set number of pins to 8. I named the port "POWER"
Next I selected "Display as Bus" mapping.
Then I went to "pins" tab and set the pin designation.
I am having trouble setting the value of "PORT" in code.
The intellisense in PSOC creator shows "POWER_0, POWER_1 etc but I cannot work out correct syntax to do equivalent of POWER_Write(23) for instance.
Have I set this up wrong or simply not using corect syntax?
Thanks
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello DaHu.
The example by Moto is perfect when you have an entire 8-bit port available.
When you have random GPIO's from several ports, you can use the Control_Reg component. Now you can connect just about any GPIO output pin to the Control Reg output signal.
To write to this component is very simple.
Control_Reg_1_Write(i); /* where i is uint8 */
This is not a bidirectional solution. It is for writing only to the GPIO's.
Good luck with your project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
That is an interesting question!
Although I knew that we can have a pin displayed as a bus,
I have never tried write/read as a bus.
So I used my CY8CKIT-059 and used P3[7:0] as an 8-bit bus.
schematic
POWER pin configuration
Pins
main.c
====================
#include "project.h"
#include "stdio.h"
#define STR_BUF_LEN 64
char str[STR_BUF_LEN+1] ;
void print(char *str)
{
UART_PutString(str) ;
}
int main(void)
{
int i, data ;
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
for(;;)
{
for (i = 0 ; i < 0x100 ; i++ ) {
POWER_Write(i) ;
CyDelay(500) ;
data = POWER_Read() ;
snprintf(str, STR_BUF_LEN, "%d\n\r", data) ;
print(str) ;
CyDelay(500) ;
}
}
}
====================
Tera Term log
So as far as setting pins in a port as a bus, it seems to be working.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello DaHu.
The example by Moto is perfect when you have an entire 8-bit port available.
When you have random GPIO's from several ports, you can use the Control_Reg component. Now you can connect just about any GPIO output pin to the Control Reg output signal.
To write to this component is very simple.
Control_Reg_1_Write(i); /* where i is uint8 */
This is not a bidirectional solution. It is for writing only to the GPIO's.
Good luck with your project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, that solves the issues nicely