Page 1 of 1

Doing CPU comms

Posted: Wed Jan 07, 2026 3:05 pm
by jaokim
Reading the Cyrus TRM, I’m trying to do some CPU comms. I can get the value of SIG1 is 0xdead. SIG2 comes back as 0xafbe. And hwrev comes back as 0xbeef. Depending on how I do it. SIG2 should be 0xbeef. And hwrev should be the hardware revision. So, not 0xbeef at least.

Does anyone have a snippet of code that work for reading and writing the cpu comms in x5000.
In particular I want to get the Xena stuff working.

Re: Doing CPU comms

Posted: Wed Jan 07, 2026 5:51 pm
by jaokim
For reference, this is what I', currently trying with:

Code: Select all

/**
 * See 7.1 CPU COMMS
 * Write address of register to INDEX register, then
 * read value from data address.
 */
static uint16 x5000_cpld_read(uint16 reg) {
    volatile uint16 result;
    *((uint16 *)X_INDEXREG) = reg;
    asm volatile ("eieio" : : );
    result = *((uint16 *)X_DATACHANNEL);
    return result;
}

/**
 * The m TRM indicates we should write the register to
 * the INDEX reg, and then write the value to the data channel.
 */
static void x5000_cpld_write(uint16 reg, uint16 data) {
    *((uint16 *)X_INDEXREG)     = reg;
    asm volatile ("eieio" : : );
    *((uint16 *)X_DATACHANNEL)  = data;
    asm volatile ("eieio" : : );
}

/**
 * See 7.1 CPU COMMS
 * Write address of register to INDEX register, then
 * read value from data address.
 */
static uint16 x5000_cpld_read_at_offset(uint16 reg) {
    volatile uint16 result;
    *((uint16 *)X_INDEXREG) = reg;
    asm volatile ("eieio" : : );
    result = *((uint16 *)(X_DATACHANNEL + reg));
    return result;
}

/**
 * The m TRM indicates we should write the register to
 * the INDEX reg, and then write the value to the data channel.
 */
static void x5000_cpld_write_at_offset(uint16 reg, uint16 data) {
    *((uint16 *)X_INDEXREG)     = reg;
    asm volatile ("eieio" : : );
    *((uint16 *)(X_DATACHANNEL + reg))  = data;
    asm volatile ("eieio" : : );
}

With x5000_cpld_read/write is how I interpreted the TRM
And x5000_cpld_read/write_at_offset is ore inline with how the Tabor TRM explains the way (which I tried because I couldn't get the other way working).

I've since added some delays, but without much improvement.

https://sourceforge.net/p/xena-xtools/c ... na_x5000.c