AnsweredAssumed Answered

How to config k64 uart_interrupt?

Question asked by zhai ling on Mar 12, 2017
Latest reply on Mar 15, 2017 by zhai ling

HI

   Now I want to send and recieve vary date in uart4.

for example:

 I recieve 8 byte date through uart4; I want to send demoRingBuffer[0] only one time.

how to chang it?

My configrations:

while (1)
{
/* Send data only when UART TX register is empty and ring buffer has data to send out. */

uint8_t aa;

 

// PRINTF("\r\n start \r\n");
while ((kUART_TxDataRegEmptyFlag & UART_GetStatusFlags(DEMO_UART)) && (rxIndex != txIndex))
{

UART_WriteByte(DEMO_UART, demoRingBuffer[txIndex]);
txIndex++;

txIndex %= DEMO_RING_BUFFER_SIZE;

}
if(demoRingBuffer[0]==0x23&demoRingBuffer[1]==0x41&demoRingBuffer[2]==0x55&demoRingBuffer[3]==0x66
&demoRingBuffer[4]==0x77&demoRingBuffer[5]==0x88&demoRingBuffer[6]==0x99&demoRingBuffer[7]==0xaa)
{
aa=0x01;
}
else
{
aa=0x02;
}


if((aa==0x01))
{
UART_WriteByte(DEMO_UART, demoRingBuffer[0]);
}
else
{
UART_WriteByte(DEMO_UART, demoRingBuffer[1]);
}



}
}

void DEMO_UART_IRQHandler(void)
{
uint8_t data;

/* If new data arrived. */
if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(DEMO_UART))
{
data = UART_ReadByte(DEMO_UART);

/* If ring buffer is not full, add data to ring buffer. */
if (((rxIndex + 1) % DEMO_RING_BUFFER_SIZE) != txIndex)
{
demoRingBuffer[rxIndex] = data;
rxIndex++;
rxIndex %= DEMO_RING_BUFFER_SIZE;
}
}

}

It always send 0x23; I want to send only one time.How to chang it?

Thanks and regards

zhai

Outcomes