Migrating from XHRA to XU208

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
TriHex
Newbie
Posts: 1
Joined: Sun May 19, 2019 3:25 pm

Re: Migrating from XHRA to XU208

Postby TriHex » Sun May 19, 2019 3:38 pm

Hi everyone,

i´m a EE student from germany and i designed a smal Headphone Amp with XUF208 as a perequesite for a bigger project.
At first i really like the xmos devices and i managed to port this software to my design without a problem until it came to VBUS :-)
I designed my Board according to Figure 11 in the XUF208 Datasheet and tried to set SELF_POWERED to 0, but it wont enumerate without VBUS connected.
I understood that in the XHRA Design VBUS schould always connected to 5V, but i couldnt figure out what i do have to change in software to make it work without VBUS connected to 5V.

thanks in advance
Nils
DHembree
Experienced Member
Posts: 75
Joined: Fri Apr 15, 2016 6:46 pm

Postby DHembree » Wed Jun 05, 2019 4:47 pm

I realize the stated upper limit sample rate for this solution is 384kHz, but would it be possible to implement changes in the code to extend this to 768kHz?
amc184
New User
Posts: 2
Joined: Sun Jan 08, 2017 5:03 am

Postby amc184 » Mon Jun 10, 2019 8:52 am

Hi All,

I’ve been working on an audio application using an XU208-128-TQ64, based on the XHRA to XU208 project, and I have most of the functionality I want working well. The last part is HID inputs, and that’s got me stumped right now. I have buttons attached to the following inputs, and want to allocate them to the following HID functions:
Button A X0D29 8C3 HID Play/Pause
Button B X0D30 8C4 HID Next Track
Button C X0D31 8C5 HID Previous Track
Button D X0D33 8C7 HID Mute
Based on the examples I could fine I wrote the following hidbuttons.xc:


#include <xs1.h>
#include <platform.h>
#include "devicedefines.h"

#ifdef HID_CONTROLS

/* Sets which port is used */
in port p_sw = on tile[0] : XS1_PORT_8C;

/* Sets which bits of port 8C correspond to each input */
/* Button A: X0D29, 8C3 */
#define P_GPI_BUTA_SHIFT 0x03
#define P_GPI_BUTA_MASK (1<<P_GPI_BUTA_SHIFT)
/* Button B: X0D30, 8C4 */
#define P_GPI_BUTB_SHIFT 0x04
#define P_GPI_BUTB_MASK (1<<P_GPI_BUTB_SHIFT)
/* Button C: X0D31, 8C5 */
#define P_GPI_BUTC_SHIFT 0x05
#define P_GPI_BUTC_MASK (1<<P_GPI_BUTC_SHIFT)
/* Button D: X0D33, 8C6 */
#define P_GPI_BUTD_SHIFT 0x07
#define P_GPI_BUTD_MASK (1<<P_GPI_BUTD_SHIFT)

/* Sets up HID controls */
#define HID_CONTROL_PLAYPAUSE 0x01
#define HID_CONTROL_NEXT 0x02
#define HID_CONTROL_PREV 0x04
#define HID_CONTROL_MUTE 0x20

/* Function where buttons are read, and HID commands made in response */
void UserReadHIDButtons(unsigned char hidData[])
{
/* Creates variables for each of the four buttons, and tmp to hold entire port */
unsigned a, b, c, d, tmp;

/* Imports port state into tmp */
p_sw :> tmp;

/* Buttons are active low (0 when active, 1 when inactive), so port state is inverted */
tmp = ~tmp;

/* Port state is broken into individual button states using masks defined above */
a = (tmp & (P_GPI_BUTA_MASK))>>P_GPI_BUTA_SHIFT;
b = (tmp & (P_GPI_BUTB_MASK))>>P_GPI_BUTB_SHIFT;
c = (tmp & (P_GPI_BUTC_MASK))>>P_GPI_BUTC_SHIFT;
d = (tmp & (P_GPI_BUTD_MASK))>>P_GPI_BUTD_SHIFT;

/* Results of button states are applied to HID controls */
hidData[0] = (a << HID_CONTROL_PLAYPAUSE) | (b << HID_CONTROL_NEXT) | (c << HID_CONTROL_PREV) | (d << HID_CONTROL_MUTE);
}
#endif



With this file, I get nothing from the buttons at all. Using some slightly different code, I can get the buttons to function, but they seem to repeat the HID function the entire time they are held down (so muting and unmuting many times, or skipping forward 10 tracks). Holding down a button for more than a second seems to send so many calls it can crash the audio player.

I’m not great at coding, and really hope one of you guys can point out where I’ve gone wrong.

Thanks,
Anton

Who is online

Users browsing this forum: No registered users and 0 guests