cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Rova_1179706
New Contributor II

Hello Cypress users,

Project

I am using the $10 PSoC 5LP kit with a USB socket.
What I want to to do is send a key (or multiple keypresses) when a button is pressed.

AN58726 was my guide for configuring the USBFS component.

Setup

I have a digital input connected to debouncer which negative flank is connected to a interrupt component.

Interrupts are enabled, and is started with isr_StartEx(BIG_Btn_isr).

Inside the CY_ISR(BIG_Btn_isr) I want to use the following code:

    while(!USBFS_bGetEPAckState(1));

    Keyboard_Data[0] = 0x00;

    Keyboard_Data[2] = aASCII_ToScanCode['c' - 0x20];

    USBFS_LoadInEP(1, Keyboard_Data, 8);

    while(!USBFS_bGetEPAckState(1));

    Keyboard_Data[0] = 0x00;

    Keyboard_Data[2] = 0x00;

    USBFS_LoadInEP(1, Keyboard_Data, 8);

    while(!USBFS_bGetEPAckState(1));

    Keyboard_Data[0] = 0x00;

    Keyboard_Data[2] = aASCII_ToScanCode['a' - 0x20];

    USBFS_LoadInEP(1, Keyboard_Data, 8);

    while(!USBFS_bGetEPAckState(1));

    Keyboard_Data[0] = 0x00;

    Keyboard_Data[2] = 0x00;

    USBFS_LoadInEP(1, Keyboard_Data, 8);

    while(!USBFS_bGetEPAckState(1));

    Keyboard_Data[0] = 0x00;

    Keyboard_Data[2] = aASCII_ToScanCode['t' - 0x20];

    USBFS_LoadInEP(1, Keyboard_Data, 8);

    while(!USBFS_bGetEPAckState(1));

    Keyboard_Data[0] = 0x00;

    Keyboard_Data[2] = 0x00;

    USBFS_LoadInEP(1, Keyboard_Data, 8);

    while(!USBFS_bGetEPAckState(1));

Problem:

When above code is placed inside the for-loop it displays "cat", exactly as predicted.

When above code is placed inside the setup it displays "cat", exactly as predicted.

When above code is placed inside the interrupt it outputs 1 enourmous string of c's: "cccccccccccccccccccccccccccccccccc" until i remove the device.

I don't understand why it failed inside the interrupt.

0 Likes
1 Solution
Rova_1179706
New Contributor II

Discovered the problem:

The USB-interrupts must be higher then the button-interrupts.

By default they are all 7, USB needs to be 6 or higher.

View solution in original post

0 Likes
1 Reply
Rova_1179706
New Contributor II

Discovered the problem:

The USB-interrupts must be higher then the button-interrupts.

By default they are all 7, USB needs to be 6 or higher.

View solution in original post

0 Likes