cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC Creator & Designer Software

j_connor
New Contributor

Hi,

I am working on small project where porting STM32+ChibiOS application into PSoC4 4200

I pretty much converted most of them but having some issue with setting up GPIO 

 

init
{
palSetPadMode(GPIOD, 1, PAL_MODE_INPUT_PULLUP);
palSetPadMode(GPIOB, 0, PAL_MODE_OUTPUT_PUSHPULL);
}while(1)
{
palClearPad(GPIOB, 0);
wait_us(50);
palReadPad(GPIOD, 1);
palSetPad(GPIOB, 0);
}

 

Above code is from original project and I need to port them into PSoC Creator.

"while" section, I think I can convert them by using per pin api like
CyPins_ClearPin()
CyPins_ReadPin()
CyPins_SetPin()

 

However, I dont know how to set init pins.

PAL_MODE_INPUT_PULLUP:

input_pullupinput_pullup

 

PAL_MODE_OUTPUT_PUSHPULL:

output_pushpulloutput_pushpull

 

I configured eachpin this way but doesnt seem to be working.

 

What am I missing or incorrectly setup?

 

Thanks

0 Likes
1 Solution
MotooTanaka
Esteemed Contributor

Hi,

I think that if you set an input as resistor pulled-up the initial drive state should be High (1).

002-COL_1.JPG

ROW_1 seems to be OK to me.

So I tried this with my CY8CKIT-042.

To test, I assigned COL_1 to SW2 (P0.7), ROW_1 to LED_G (P0.2).

(Probably you want to assign them to other pins in your application)

Schematic

001-schematic.JPG

Pins

004-pins.JPG

main.c

#include "project.h"

int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    while(1)
    {
        ROW_1_Write(0) ;
        COL_1_Read() ;
        ROW_1_Write(1) ;
    }
}

 

As far as I debugged,

when I stopped the program at COL_1_Read(), LED was ON

and when I stopped the program at ROW_1_Write(0), LED was OFF.

 

moto

View solution in original post

0 Likes
1 Reply
MotooTanaka
Esteemed Contributor

Hi,

I think that if you set an input as resistor pulled-up the initial drive state should be High (1).

002-COL_1.JPG

ROW_1 seems to be OK to me.

So I tried this with my CY8CKIT-042.

To test, I assigned COL_1 to SW2 (P0.7), ROW_1 to LED_G (P0.2).

(Probably you want to assign them to other pins in your application)

Schematic

001-schematic.JPG

Pins

004-pins.JPG

main.c

#include "project.h"

int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    while(1)
    {
        ROW_1_Write(0) ;
        COL_1_Read() ;
        ROW_1_Write(1) ;
    }
}

 

As far as I debugged,

when I stopped the program at COL_1_Read(), LED was ON

and when I stopped the program at ROW_1_Write(0), LED was OFF.

 

moto

View solution in original post

0 Likes