int WriteCB_SG_IR(uint32_t index) {
int cs = 0;
uint32_t CBSGIR_OFFSET = 142;
uint32_t CBSGIR_CTRL_OFFSET = 147;
const uint32_t SWREG_BASE = 0;
uint32_t CB_SG_IR_ADDRESS = SWREG_BASE + CBSGIR_OFFSET;
uint32_t CB_SG_IR_ADDRESS_CTL = SWREG_BASE + CBSGIR_CTRL_OFFSET;
if (index >= 64) {
return -1;
}
uint32_t RTAGOFFSET_0 = 0;
uint32_t RTAGOFFSET_1 = 0;
uint32_t RTAGOFFSET_2 = 0;
uint32_t RTAGOFFSET_3 = 0;
uint32_t RTAGOFFSET_4 = 0;
uint32_t RTAGOFFSET_5 = 0;
uint32_t RTAGOFFSET_6 = 0;
uint32_t RTAGOFFSET_7 = 0;
uint32_t RTAGOFFSET_8 = 0;
uint32_t RTAGOFFSET_9 = 0;
uint32_t RTAGOFFSET_10 = 0;
uint32_t REPLACE_PORTS = 0;
uint32_t TAG_PORTS = 0x7FF;
uint32_t SEQ_REC_PORTS = 0;
uint32_t IND_REC_PORTS = 0;
uint32_t IND_REC_TIMEOUT = 0;
uint32_t SEQRECOFFSET = 0;
uint32_t GENSEQNUM = 0x1;
uint32_t SEQGENRST = 0;
uint32_t VALID = 1U;
uint32_t RDWRSET = 1U;
uint32_t TARGETEDTBL = 0;
uint32_t CB_SG_IR_Entry[CB_SGIR_ADDR_RANGE] = {0};
CB_SG_IR_Entry[0] =
((GENSEQNUM & 0x1) << 28) |
((SEQRECOFFSET & 0x1F) << 29) |
((IND_REC_TIMEOUT & 0xFFFF) << 34);
CB_SG_IR_Entry[1] =
((SEQ_REC_PORTS & 0x7FF) << 0) |
((IND_REC_PORTS & 0x7FF) << 11);
CB_SG_IR_Entry[2] =
((TAG_PORTS & 0x7FF) << 0) |
((REPLACE_PORTS & 0x7FF) << 11);
CB_SG_IR_Entry[3] =
((RTAGOFFSET_0 & 0x3F) << 0) |
((RTAGOFFSET_1 & 0x3F) << 6) |
((RTAGOFFSET_2 & 0x3F) << 12) |
((RTAGOFFSET_3 & 0x3F) << 18) |
((RTAGOFFSET_4 & 0x3F) << 24);
CB_SG_IR_Entry[4] =
((RTAGOFFSET_5 & 0x3F) << 0) |
((RTAGOFFSET_6 & 0x3F) << 6) |
((RTAGOFFSET_7 & 0x3F) << 12) |
((RTAGOFFSET_8 & 0x3F) << 18) |
((RTAGOFFSET_9 & 0x3F) << 24) |
((RTAGOFFSET_10 & 0x3F) << 30);
uint32_t status = 0;
status = spi_read_DynamicEntry(CB_SG_IR_ADDRESS_CTL, cs);
uint8_t counter = 0;
while ((status & (1 << 31)) != 0){
counter++;
status = spi_read_DynamicEntry(CB_SG_IR_ADDRESS_CTL, cs);
}
for (int i = 0; i < CB_SGIR_ADDR_RANGE; i++) {
Std_ReturnType ret = spi_write_DynamicEntry(CB_SG_IR_ADDRESS + i, CB_SG_IR_Entry[i]);
if (ret != E_OK) {
return -2;
}
uint32_t readBack = 0;
ret = spi_read_DynamicEntry(CB_SG_IR_ADDRESS + i, &readBack);
if (ret != E_OK || readBack != CB_SG_IR_Entry[i]) {
return -3;
}
}
uint32_t CTRL_VALUE = (VALID << 31) |
(RDWRSET << 30) |
(SEQGENRST << 9) |
(TARGETEDTBL << 6) |
(index & 0x3F);
Std_ReturnType ret = spi_write_DynamicEntry(CB_SG_IR_ADDRESS_CTL, CTRL_VALUE);
if (ret != E_OK) {
return -4;
}
do {
ret = spi_read_DynamicEntry(CB_SG_IR_ADDRESS_CTL, &status);
if (ret != E_OK) {
return -5;
}
} while ((status >> 31) & 1U);
return 0; // Success
}
I am trying to create a Dynamic Entry for CB Sequence Generation and Recovery Table in which followed up the example from SJA1110 EVM Host tools CB_SG_IR.py. where i am facing some issue with the bit settings
Add on to that, see when we are configuring this
((GENSEQNUM & 0x1) << 28) |
((SEQRECOFFSET & 0x1F) << 29) |
((IND_REC_TIMEOUT & 0xFFFF) << 34);
IND_REC_TIMEOUT value is written after 32 bit register value which is we are exceeding the 32 bits where the values will be written into the wrong register ryt?? can you double check whether it will be written within 32bit register
One more thing when i debug, i could see the CB_SG_IR_Entry[0] is written with some values what we are expecting to write but in the case of other CB_SG_IR_Entr[1],[2],[3] there is no value written
I am thinking the root cause of the issue is due to bit change ??
As you mentioned the spi_read and spi_write is as same as L2 Lookup table which i used to configure dynamically which is working fine in L2 Lookup table.
Is there any other thing we are missing out ??