- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As silly as it sounds, I have been fiddling for hours to get my project to read a digital input pin.
The device is a PSOC 4200 (SSOIC-28)
I have a Digital Input pin on P4[0], P4[1] and P4[2].
I see from the technical manual there are limitations on P4 with routing but it appears the pins can be used as GPIO.
My Power supply is 3V
The signals are slow (1 is a 100ms enable signal and the other a 2ms period clock and data pin)
I have tried CMOS trip levels, transparency mode, buffer on and off, high impedance, pull down, initial value = 0, initial value = 1.
I have a logic analyser connected to the input pins on the micro and the signal is stable and consistant, packets are being sent every 350ms.
I have tried CyPins_ReadPin(PINALIAS) and PIN_Read() but neither is detecting the high level of pin.
Earlier I did have an interrupt running on one of the pins and it was working but when single stepping the code, the interrupt remained being tripped by new packets coming in and causing the code to branch to isr. I changed back to pin read in an attempt to read the pin
My last attempt is bundled up and attached.
Surely, I have done something stupid, I cannot imagine reading a digital input pin would be so involved.
I will attach the wavforms in next post
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I finally have the digital inputs working. Now just need to figure out how to make one of them an interrupt in firmware.
For my 3 pins on Port 4;
CY_SYS_PINS_SET_DRIVE_MODE(CYREG_PRT4_PC,0,CY_SYS_PINS_DM_DIG_HIZ);
CY_SYS_PINS_SET_DRIVE_MODE(CYREG_PRT4_PC,1,CY_SYS_PINS_DM_DIG_HIZ);
CY_SYS_PINS_SET_DRIVE_MODE(CYREG_PRT4_PC,2,CY_SYS_PINS_DM_DIG_HIZ);
CyGlobalIntEnable;
for(;;){
WakePin = CY_SYS_PINS_READ_PIN(CYREG_PRT4_PS,2);
if(WakePin){
SampleLFData();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had to change a bit to make your project run on a Pioneer Kit:
Connect P2_6 (J3 1) ---- J2 P0_3 (LED Blue) as indicator
P4_0 now input for WAKE (J3 10) since the original pin is only used internally.
Changing WAKE changes the LED from off to on as expected --- No error
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob,
How did you read the digital inputs? I tried all sorts of combinations an eventually only managed to get them working using the read pins code shown in my last post.
As I do not now have the pin components on the scematic, I am not sure how to set up an interrupt for the pins entirely in firmware?
I presume I need to use some API call to set the pin (say p4.2) as an input and then define an interrupt for it and us ethe startex?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am still working on your problem, but I did not understand yet why you are doing the configuration dynamically and not by setting the properties of the pin component.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Orbitcoms,
please, can you be so kind, can you share - attatch the DataSheet of the AS3393 device?
Viktor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Attached latest elaborate. Reading of pins I usually do with the _Read() API which is able to read several pins of a port at once.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@bob: yes you did, but your actions did not match your speech 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@hli
My mouse was scared by one of my seven cats ;-))
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob,
So, for PSCO4 port 4 port pins, you need to read the entire port and then check the pin states of interest. Rather than doing a bitwise read per pin?
ie.
PortState = MYPORT_Read()
if(PortState & 0x01){
//P4.0 is high
}
Then if I want interrupt, I add isr for the entire port and look at which pin caused int in the handler routine? (I want to sleep the device and only wake up on a particulr pin going high).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This might help -
http://www.cypress.com/?rID=93401 AN86439 - PSoC® 4 - Using GPIO Pins
http://www.cypress.com/?rID=95069 AN90799 - PSoC® 4 Interrupts
http://www.cypress.com/?rID=38267 AN54460 - PSoC® 3, PSoC 4, and PSoC 5LP Interrupts
Regards, Dana.