This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi.
I'm trying to get SCI Error injection result through loop back test.
But I didn't get to want result.
Documen SPNU551B, SCI7 : Frame Error Dectection.
I implemented Frame Error Injection through loob back mode.
No Interrupt occured.
My code is follow by:
---------------------------------------------------------------------------------------------
{
.................
sciInit();
while(sciIsIdleDetected(sciREG))
{
/* NOP */
};
sciREG->GCR1 = sciREG->GCR1 | (uint32)((uint32)1 << 16U) /* Loop back Enable */
sciEnableLoopback(sciREG, Digital_Lbk);
sciREG->IODFTCTRL = sciREG->IODFTCTRL | (uint32)((uint32)1 << 26U); /* enable Frame Error in Loopback Test Mode */
........................wait for interrupt ....................................
sciDisableLoopback(sciREG);
sciREG->GCR1 = sciREG->GCR1 | (uint32)~((uint32)1 << 16U); /* Loopback mode disable */
-----------------
}
----------------------------------------------------------------------------------------------------
void sciNotification(sciBASE_t *sci, uint32 flags)
{
/* enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (29) */
switch(flags)
{
case SCI_FE_INT:
sciREG->IODFTCTRL = sciREG->IODFTCTRL & (uint32)~((uint32)1 << 26U); /* Disable Frame Error in Loopback mode */
(void)SerialPutString("\r\n Loopback Test Mode : Frame Error has Occured!!!\r\n");
break;
case SCI_RX_INT:
SciInterrupt();
break;
default:
break;
}
/* USER CODE END */
}
----------------------------------------------------------------------------------------------------
void sciInit(void)
{
/* USER CODE BEGIN (2) */
/* USER CODE END */
/** @b initialize @b SCI */
/** - bring SCI out of reset */
sciREG->GCR0 = 0U;
sciREG->GCR0 = 1U;
/** - Disable all interrupts */
sciREG->CLEARINT = 0xFFFFFFFFU;
sciREG->CLEARINTLVL = 0xFFFFFFFFU;
/** - global control 1 */
sciREG->GCR1 = (uint32)((uint32)1U << 25U) /* enable transmit */
| (uint32)((uint32)1U << 24U) /* enable receive */
| (uint32)((uint32)1U << 5U) /* internal clock (device has no clock pin) */
| (uint32)((uint32)(1U-1U) << 4U) /* number of stop bits */
| (uint32)((uint32)0U << 3U) /* even parity, otherwise odd */
| (uint32)((uint32)0U << 2U) /* enable parity */
| (uint32)((uint32)1U << 1U); /* asynchronous timing mode */
/** - set baudrate */
sciREG->BRS = 6U; /* baudrate */
/** - transmission length */
sciREG->FORMAT = 8U - 1U; /* length */
/** - set SCI pins functional mode */
sciREG->PIO0 = (uint32)((uint32)1U << 2U) /* tx pin */
| (uint32)((uint32)1U << 1U); /* rx pin */
/** - set SCI pins default output value */
sciREG->PIO3 = (uint32)((uint32)0U << 2U) /* tx pin */
| (uint32)((uint32)0U << 1U); /* rx pin */
/** - set SCI pins output direction */
sciREG->PIO1 = (uint32)((uint32)0U << 2U) /* tx pin */
| (uint32)((uint32)0U << 1U); /* rx pin */
/** - set SCI pins open drain enable */
sciREG->PIO6 = (uint32)((uint32)0U << 2U) /* tx pin */
| (uint32)((uint32)0U << 1U); /* rx pin */
/** - set SCI pins pullup/pulldown enable */
sciREG->PIO7 = (uint32)((uint32)0U << 2U) /* tx pin */
| (uint32)((uint32)0U << 1U); /* rx pin */
/** - set SCI pins pullup/pulldown select */
sciREG->PIO8 = (uint32)((uint32)1U << 2U) /* tx pin */
| (uint32)((uint32)1U << 1U); /* rx pin */
/** - set interrupt level */
sciREG->SETINTLVL = (uint32)((uint32)0U << 26U) /* Framing error */
| (uint32)((uint32)0U << 25U) /* Overrun error */
| (uint32)((uint32)0U << 24U) /* Parity error */
| (uint32)((uint32)0U << 9U) /* Receive */
| (uint32)((uint32)0U << 8U) /* Transmit */
| (uint32)((uint32)0U << 1U) /* Wakeup */
| (uint32)((uint32)0U << 0U); /* Break detect */
/** - set interrupt enable */
sciREG->SETINT = (uint32)((uint32)1U << 26U) /* Framing error */
| (uint32)((uint32)1U << 25U) /* Overrun error */
| (uint32)((uint32)0U << 24U) /* Parity error */
| (uint32)((uint32)1U << 9U) /* Receive */
| (uint32)((uint32)0U << 1U) /* Wakeup */
| (uint32)((uint32)0U << 0U); /* Break detect */
/** - initialize global transfer variables */
g_sciTransfer_t[0U].mode = (uint32)0U << 8U;
g_sciTransfer_t[0U].tx_length = 0U;
g_sciTransfer_t[0U].rx_length = 0U;
/** - Finaly start SCI */
sciREG->GCR1 |= 0x80U;
}
----------------------------------------------------------------------------------------------------
That's all.
I'd like to get a advise what my miss .
Looking forward to response.
best regards.
Gene
Hello Jinwook,
You did not transmit data after the FEN is enabled and loopback is enabled..
Hello Wang.
Thank you for your reply.
Unfortunately, I added the code according to your advice, but it's still the same.
Added Code is follow by:
-----------------------------------------------------------------------------------------------------
...
sciREG->GCR1 = sciREG->GCR1 | (uint32)((uint32)1 << 16U) /* Loop back Enable */
sciEnableLoopback(sciREG, Digital_Lbk);
sciREG->IODFTCTRL = sciREG->IODFTCTRL | (uint32)((uint32)1 << 26U); /* enable Frame Error in Loopback Test Mode */
sciSendByte(sciREG,0xA5); /* Added Code */
........................wait for interrupt ....................................
sciDisableLoopback(sciREG);
sciREG->GCR1 = sciREG->GCR1 | (uint32)~((uint32)1 << 16U); /* Loopback mode disable */
----------------------------------------------------------------------------------------------------
That's all.
If my implementation is wrong, can you provide the correct example?
Best regards.
Gene.
Hello, Wang.
I resolved problem in myself.
For Frame Error Injection, I needed to set "Analog Loopback Mode".
Thank you for your help.
Best regards.
Gene.