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.

SCI always sets framing error

Other Parts Discussed in Thread: CONTROLSUITE

Hi folks,

I am trying to get the SCI working on the F28027. I am working from some SCI code that I used on a previous project on the same device and was working there and also from the SCI echo back example project.

As in the echo back example I have enabled FIFOs and use polling of the Rx FIFO status to check when the FIFO has received data. However For every byte I send from the hyper terminal I receive two bytes (scope shows there is only the one expected byte sent on the line).

Neither of the bytes received seem to have any correlation to the ASCII data that is sent and the SCIRXST always reports a framing error. Having checked the values in all the SCI settings registers and compared them to the working echo back project I am at a loss as to why this should happen.

I am using the same UART settings in the Hyper terminal as with the echo back project

An example data scenario is: I type in the hyperterminal: "11111"

Then the data "received" by the SCI shows as: "8006 0087 8006 00F8 8006 00F8 8006 00F8 8006 0087"

My SCI code is as below:

// The baudRate is set to SCI_BaudRate_9_6_kBaud when called by main(), which has already set the low speed clock to 15MHz.
int16_t SCI_CTRL_config(const SCI_CTRL_Handle sciCtrlHandle, const SCI_BaudRate_e baudRate) {
	int16_t e = EXIT_SUCCESS;

	CLK_enableGpioInputClock(clk);	/* Enable clock to GPIO. */
	CLK_enableSciaClock(clk);	/* Enable clock to SCI-A. */

	/* Configure GPIO lines for SCI-A port. */
	GPIO_setDirection(sciCtrlHandle->gpio, GPIO_SCIRX_LINE_NUMBER, GPIO_Direction_Input);
	GPIO_setPullUp	 (sciCtrlHandle->gpio, GPIO_SCIRX_LINE_NUMBER, GPIO_PullUp_Enable);
	GPIO_setQualification(sciCtrlHandle->gpio, GPIO_Number_28, GPIO_Qual_ASync);
	GPIO_setMode	 (sciCtrlHandle->gpio, GPIO_SCIRX_LINE_NUMBER, GPIO_28_Mode_SCIRXDA);

	GPIO_setDirection(sciCtrlHandle->gpio, GPIO_SCITX_LINE_NUMBER, GPIO_Direction_Output);
	GPIO_setPullUp	 (sciCtrlHandle->gpio, GPIO_SCITX_LINE_NUMBER, GPIO_PullUp_Disable);
	GPIO_setMode	 (sciCtrlHandle->gpio, GPIO_SCITX_LINE_NUMBER, GPIO_29_Mode_SCITXDA);

	/* Configure SCI-A communication. */
	SCI_setNumStopBits (sciCtrlHandle->sci, SCI_NumStopBits_One);
	SCI_disableParity  (sciCtrlHandle->sci);
	SCI_disableLoopBack(sciCtrlHandle->sci);
	SCI_setMode        (sciCtrlHandle->sci, SCI_Mode_IdleLine);
	SCI_setCharLength  (sciCtrlHandle->sci, SCI_CharLength_8_Bits);

	/* Configure SCI-A control. */
	SCI_disableRxErrorInt(sciCtrlHandle->sci);
	SCI_disableTxWake    (sciCtrlHandle->sci);
	SCI_disableSleep     (sciCtrlHandle->sci);
	SCI_enableTx         (sciCtrlHandle->sci);
	SCI_enableRx         (sciCtrlHandle->sci);

	SCI_setBaudRate(sciCtrlHandle->sci, (SCI_BaudRate_e)baudRate);

	SCI_enableRxInt(sciCtrlHandle->sci);
	SCI_enableTxInt(sciCtrlHandle->sci);

	/* Configure SCI-A RX fifo. */
	SCI_enableFifoEnh    (sciCtrlHandle->sci);
	SCI_resetTxFifo      (sciCtrlHandle->sci);
	SCI_clearTxFifoInt   (sciCtrlHandle->sci);
	SCI_resetChannels    (sciCtrlHandle->sci);
	SCI_setTxFifoIntLevel(sciCtrlHandle->sci, SCI_FifoLevel_Empty);

	/* Configure SCI-A TX fifo. */
	SCI_clearRxFifoOvf   (sciCtrlHandle->sci);
	SCI_resetRxFifo      (sciCtrlHandle->sci);
	SCI_clearRxFifoInt   (sciCtrlHandle->sci);
	SCI_setRxFifoIntLevel(sciCtrlHandle->sci, SCI_FifoLevel_4_Words);

	SCI_enable(sciCtrlHandle->sci);
	return e;
}

// This is called from the super-loop at bottom of main(), which does nothing else.
void SCI_CTRL_blockingReadAll(SCI_CTRL_Handle sciCtrlHandle) {
	while(SCI_getRxFifoStatus(sciCtrlHandle->sci) < SCI_FifoStatus_1_Word)
	{
	}
	trace = (trace << 8) | *((uint16_t *)0x7055);
	uint16_t d = SCI_getData(sciCtrlHandle->sci);
	QUE_enqueue(sciCtrlHandle->rxQue, &d, 1);
}

The signal to the C28x on the scope looks perfect, straight edges, correct levels, correct timing, etc

  • Hi Toby,

    It can due to following issues:
    1. Improper Baud rate
    2. Absence of level shifter circuitry or USB to serial converter

    BTW what hardware are you using? Dev kit or custom one?

    Regards,
    Gautam
  • Hi Gautam,

    I'm using the LanchPad XL board with SCI over the USB connection. S4 is set to ON and I am probing with scope on J1-3 & J1-4.

    If I use the example SCI echo-back project, the levels and timing are exactly the same on the scope (i.e. 0-3v3 logic levels, 1 bit per just over 100us [9600 baud], 1 start bit 8 data bits, no parity bit and 1 stop bit).

    Sending the same character from Hyper terminal when running either projects results in exactly the same waveform, e.g. sending character '1' results in 0x31 data sent LSB first.

    Both projects use internal oscillator 1 with PLL multiplier of 12 and a divide of 2 (yielding f_clk = (10MHz * 12) / 2 = 60MHz).

    The low speed prescalar is 2 (yielding f_lospclk = 60MHz/(2 * 2) = 15MHz).

    The clock to the SCI peripheral is enabled. 

    The SCILBAUD register has 194.

    I dont know what else I could check to see if the baud setting might be incorrect or different to that of the example project...

    Rgds, T

  • So just one question, does the sci_echoback example work properly or not?
  • Yes, the echo-back example works perfectly.
  • A request Toby, can you modify this example:
    C:\ti\controlSUITE\device_support\f2802x\v230\f2802x_examples_structs\sci_echoback

    This is based on structure rather than driver based. Once done and if still not working share the code.

    Regards,
    Gautam
  • I'm such a dunder-head :0

    I exported the registers view to a text file from the working example project and my non-working project and did a diff on the files.
    My low speed clock pre scalar was actually incorrect, d'oh!!
  • Great you were able to spot the error.

    Goodluck & Regards,
    Gautam