Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > Port Register Writing Help

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Port Register Writing Help
Moderator:
ANCY

Post Reply
Follow this topic



Port Register Writing Help

daiengineering posted on 30 Apr 2012 1:41 PM PST
Member
2 Forum Posts

 

Hello! I was looking at learning how to use port registers for PSOC5, but I keep getting numerous errors. Here's the code which simply sets all pins on Port0 as pull up resistors. 

 

#include <device.h>

 

void main(void)

{

while(1)

{

    PRT0DM0=0xFF;

 PRT0DM1=0xFF;

 PRT0DM2=0x00;

 PRT0DR=0x01;

}

}

 

'PRT0DM0' undeclared (first use in this function) 

'PRT0DM1' undeclared (first use in this function) 

'PRT0DM2' undeclared (first use in this function) 

'PRT0DR' undeclared (first use in this function) 

The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

Thank you! 

 

 




Re: Port Register Writing Help

Bob Marlowe posted on 30 Apr 2012 03:25 PM PST
Top Contributor
1768 Forum Posts

Differently from PSoC1 the port registers and pins are addressed with some other functions.

Have a look at Help -> Documentation -> System Reference -> System Reference Guide in PSoC Creator. In chapter 7 there are descriptions of the APIs to access port-pins. I would strongly avoid to set the modes of pins via registers. There is a sophisticated configuration dialog allowing to specify some more properties than in a PSoC1.

 

Bob



Re: Port Register Writing Help

U2 posted on 01 May 2012 01:20 AM PST
Cypress Employee
589 Forum Posts

 The code does not compile because, the compiler does not recognise PRT0DM0, PRT0DM1 and PRT0DM2. The register defintions for any device is present in the file, "cydevice_trm.h". PRT0DM0 is accessed as CYREG_PRT0_DM0. 



Re: Port Register Writing Help

U2 posted on 01 May 2012 01:22 AM PST
Cypress Employee
589 Forum Posts

 Since the defintion actually includes the register address it is recommended to use the following API.

CY_SET_REG8(CYREG_PRT0_DM0,0xFF);

CY_SET_REG8(CYREG_PRT0_DM1,0xFF);

CY_SET_REG8(CYREG_PRT0_DM2,0xFF);



Re: Port Register Writing Help

U2 posted on 01 May 2012 01:22 AM PST
Cypress Employee
589 Forum Posts

 You can find these API defintions in "cytypes.h" file.






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20