- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
psoc1,how to get a pin input value?
select StdCPU and High Z Analog?
What is StdCPUInput?
Thank you!
Solved! Go to Solution.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum!
StdCPU means: the pin's logical value can be read by the CPU. To get a digital input pin set the drive-mode to High-Z.
You read a pin by reading the complete port and mask out all unused pins by
PRTnDR & (0x01 << PinNumber) where n is the port number 0,1 etc and PinNumber is 0..7
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum!
StdCPU means: the pin's logical value can be read by the CPU. To get a digital input pin set the drive-mode to High-Z.
You read a pin by reading the complete port and mask out all unused pins by
PRTnDR & (0x01 << PinNumber) where n is the port number 0,1 etc and PinNumber is 0..7
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Bob!
But I fail again. I set P7 stdcpu stong,P8 stdcpu High Z Analog,P9 stdcpu stong.And I connect P7 and P8,then P9 havent set high final.I can measure P7 is high. Please help.
My code:
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "PSoCGPIOINT.h"
#define P7_1() P7_Data_ADDR |= P7_MASK
#define P7_0() P7_Data_ADDR &= (~P7_MASK)
#define P8_1() P8_Data_ADDR |= P8_MASK
#define P8_0() P8_Data_ADDR &= (~P8_MASK)
#define P9_1() P9_Data_ADDR |= P9_MASK
#define P9_0() P9_Data_ADDR &= (~P9_MASK)
#define Get_P8() P8_Data_ADDR & P8_MASK
void Delay_ms(int x)
{
int y;
int z;
for (y=0; y<x; y++)
for (z=0; z<51; z++) //1ms delay when CPUCLK=24MHz
{
z++;z--;z++;z--;
}
}
void main(void)
{
// Insert your main routine code here.
P7_1();
while(1)
{
if(Get_P8())
{
P9_1();
}else
{
P9_0();
}
Delay_ms(100);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By the way,I am using cy8c20446.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please do not provide code snippets only. Can you post your complete project, so that we all can have a look at all of your settings? To do so, use
Designer->File->Archive Project...
and attach the resulting file.
Are you trying to learn PSoC? If so, I would suggest you to use a (more modern) prototyping kit which allows you to debug your program.
Bob