- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rova, it is an old post but would be able to share you project? or you function aASCII_ToScanCode. Thank you