- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
I want to use my XMC4700 MCU to communicate with other module using SPI protocol (I want use USIC hardware in the MCU, I don't want to use bit banging by software to create SPI pulses). Can I be able to do that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @90670 ,
Here we have three example codes in Github: XMC+USIC+SPI , you can refer to the codes and check if this meet your requirements, hope this can help you.
Regards,
Owen_Su
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @90670 ,
Here we have three example codes in Github: XMC+USIC+SPI , you can refer to the codes and check if this meet your requirements, hope this can help you.
Regards,
Owen_Su
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you a lot! @Owen_Su Can I ask you another question about the hardware? I see that USIC has FIFO buffer and they often used in UART or other serial communication. But I don't understand much about hardware, can you explain to me what is this FIFO and what is it used for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @90670 ,
FIFO: First in, First out (like a queue).
In USIC, it provides Optimal shared 64 word FIFO buffer for personal use. With the FIFO buffer, it will offload the CPU to perform other critical task.
Hope this can help you.
Regards,
Owen_Su
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot! I'm using this in my UART communication. I have another struggle here. I see that UART APPs can attach HW signal connection such as when UART receive, it will trigger "event_std_receive" to some INTERRUPT APP to trigger ISR for that received data. But how can I know how many byte of data it received before it triggers every ISR? Below are my example source. Hope you can support me with this. Thank you @Owen_Su !
-----------
#include "DAVE.h" //Declarations from DAVE Code Generation (includes SFR declaration)
//Pre-condition:
//Receive mode should be configured as "Direct".
//Description:
//Transmits 10 bytes of data after receiving 10 bytes of data.
uint32_t TimerId;
uint8_t Global_UartReceiveData = 0;
char Buffer_UartReceiveData[5];
uint8_t UART_Index = 0;
bool Uart_TransmitBusy = false;
uint8_t start_data[] = "Hello\n";
uint8_t stop_data[] = "Bye\n";
void UART_Procedure(void);
int main(void)
{
DAVE_STATUS_t init_status;
uint8_t ReadData[10];
init_status = DAVE_Init();
//create a new software timer
//1us but not 1s, timer type is one shot
TimerId = (uint32_t)SYSTIMER_CreateTimer(1,SYSTIMER_MODE_ONE_SHOT,(void*)UART_Procedure,NULL);
if(init_status != DAVE_STATUS_SUCCESS)
{
while(1U)
{
}
}
/*place holder for user application*/
while(1U)
{
}
return 0U;
}
//trigger by software timer interrupt
void UART_Procedure(void)
{
uint32_t Buffer_word = 0;
Buffer_word = Buffer_UartReceiveData[0];
Buffer_word = Buffer_word << 8;
Buffer_word = Buffer_word | Buffer_UartReceiveData[1];
Buffer_word = Buffer_word << 8;
Buffer_word = Buffer_word | Buffer_UartReceiveData[2];
// if (Buffer_word == 4745505)
if(Buffer_word != 0)
{
UART_Transmit(&UART_0, start_data, sizeof(start_data));
while(Uart_TransmitBusy){};
}
// if (Buffer_word == 4356453)
// {
// UART_Transmit(&UART_0, stop_data, sizeof(stop_data));
// while(Uart_TransmitBusy){};
// }
UART_Index = 0;
}
//UART_Receive_Block, trigger every time UART object receive data
void UART_Receive_ISR(void)
{
//Registers a request for receiving data over UART channel
//1 letter
UART_Receive(&UART_0, &Global_UartReceiveData, 1);
Buffer_UartReceiveData[UART_Index] = Global_UartReceiveData;
UART_Index++;
if(UART_Index==4)
{
//Starts the software timer
//4 letters
SYSTIMER_StartTimer(TimerId);
}
}
//trigger every time UART transmit done 1 byte
void EndOfTransmitCallback_ISR(void)
{
//End of transmit (status)
Uart_TransmitBusy = false;
}
-----------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @90670 ,
You can follow the 'Help content' to configure your UART APP, after you complete the configuration, click 'Generate code' and your codes will help you set the mode. I think that you can obtain the size of data from this part, and you can refer to the coed below. Hope this can help you.
Hope this can help you.
Regards,
Owen_Su