- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have an application running on a TC377 board. It uses a timer interrupt to control that the application runs every 1ms.
For now, I've just been feeding the inputs with dummy data. However, I would now like to stream data from log files that I have stored on my computer. There are around 10 inputs and I have 10 seconds of data (sampled at 1ms), and I would also like to transmit the data to the board at the same rate. Any examples around on how I would go about doing this, and right now I'm just connected via USB, will this be possible at all?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @new_aurix_dev ,
Thank you for your interest in Infineon's products and for the opportunity to serve you.
To be honest, I'm not very clear with your purpose, whether you want to send a stream data to the TC377 from the PC via the USB interface, so I was wondering if you can clarify it again.
Looking forward to your reply.
BR,
Jeremy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Jeremy_Zhou
Thank you for your response. Yes, that is exactly what I want to accomplish. Essentially I have several signals logged from another simulation (sampled at 1000 Hz) and I would now like to feed them to the board in "real-time", in order to verify the functionality of my application when it runs on the Aurix board. Which also requires me to log data FROM the board to the computer as well (also at 1000 Hz). For now I've just used OneEye to measure and log the outputs, however it seems that the sampling rate is limited to 7-8 ms intervals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @new_aurix_dev ,
Thanks for your clarification.
According to your statement, the new data will be generated per 1 ms, and to implement transmit them in 'real time', it should complete the transmission in 1 ms, is it my understanding right?
The AURIX MCU doesn't integrate the USB module, the UART interface is used to transfer these data actually, so the transmission period is restricted to the Baud rate, and data length, in addition, it's also related to the software handling.
BR,
Jeremy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alright, thank you for the information. But honestly I'm a bit confused. I've tried getting the data transfer to work (at all) by looking at some of the example projects in the Aurix Dev Studio. In my naivety I thought to transfer data from the computer to the board I could write a simple script on the computer, something like:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @new_aurix_dev ,
Thanks for your reply.
It's hard to figure out the root cause just based on the above description, next, I'd like to suggest you use a serial assistant to test with the python script and AURIX board separately prior to combining them directly.
BR,
Jeremy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alright, thanks for the input. Since my last reply I've at least managed to get the communication somewhat working. However there seems to be a lot of "garbage" captured by the board. And it does not matter if I use my python script or a serial assistant tool, I see the same issue regardless.
At the moment I'm sending a float number (10152.4), which I convert to a byte-string before sending: b'\x9a\xa1\x1eF'. Sometimes the transfer is made correctly:
But equally often I end up with garbage, which "shifts" the correct bytes away.
The bytes marked in yellow are just garbage, but after that you can see that the message I actually sent is there, but just shifted because of the garbage.
On the Aurix side I'm doing the following:
#define SERIAL_BAUDRATE 115200
#define INTPRIO_ASCLIN0_RX 18
#define INTPRIO_ASCLIN0_ER 17
#define ASC_RX_BUFFER_SIZE 32
IfxAsclin_Asc g_asc;
uint8 g_ascRxBuffer[ASC_RX_BUFFER_SIZE + sizeof(Ifx_Fifo) + 8];
IFX_INTERRUPT(asclin0_Rx_ISR, 0, INTPRIO_ASCLIN0_RX);
void asclin0_Rx_ISR(void)
{
IfxAsclin_Asc_isrReceive(&g_asc);
}
IFX_INTERRUPT(asclin0_Er_ISR, 0, INTPRIO_ASCLIN0_ER);
void asclin0_Er_ISR(void){
IfxAsclin_Asc_isrError(&g_asc);
}
Then I initialize like this:
void init_UART(void)
{
IfxAsclin_Asc_Config ascConfig;
IfxAsclin_Asc_initModuleConfig(&ascConfig, &MODULE_ASCLIN0);
ascConfig.baudrate.baudrate = SERIAL_BAUDRATE;
ascConfig.interrupt.rxPriority = INTPRIO_ASCLIN0_RX;
ascConfig.interrupt.typeOfService = IfxSrc_Tos_cpu0;
const IfxAsclin_Asc_Pins pins = {
.cts = NULL_PTR,
.ctsMode = IfxPort_InputMode_pullUp,
.rx = &IfxAsclin0_RXA_P14_1_IN,
.rxMode = IfxPort_InputMode_pullDown,
.rts = NULL_PTR,
.rtsMode = IfxPort_OutputMode_pushPull,
.tx = &IfxAsclin0_TX_P14_0_OUT,
.txMode = IfxPort_OutputMode_pushPull,
.pinDriver = IfxPort_PadDriver_cmosAutomotiveSpeed1
};
ascConfig.rxBuffer = g_ascRxBuffer;
ascConfig.rxBufferSize = ASC_RX_BUFFER_SIZE;
ascConfig.pins = &pins;
IfxAsclin_Asc_initModule(&g_asc, &ascConfig);
}
And finally the read method:
void read_UART_message(void) {
unsigned char rxData[4] = {''};
Ifx_SizeT count = 4;
IfxAsclin_Asc_read(&g_asc, rxData, &count, TIME_INFINITE);
printf("Received message:\nHex: %hhx %hhx %hhx %hhx\n", rxData[0], rxData[1], rxData[2], rxData[3]);
float f;
memcpy(&f, &rxData, sizeof(f));
printf("Float: %f\n\n", f);
}
And then I just call the read_UART_message() in the main loop of cpu0.
For completeness I'll also post the very simple python code:
import serial
import struct
ser = serial.Serial('COM5', 115200)
ser.write(struct.pack('f', 10152.4))
And like I said, I get the exact same results if I use a Serial Debug Assistant tool, which leads me to believe that I'm messing up somewhere on the Aurix side.
Any help or pointers will be highly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @new_aurix_dev ,
Thanks for your reply,
For instance, "12.24" will be converted into char strings which consist 5 bytes, maybe you can the below function to print the bytes you receive.
void read_UART_message(void) {
char rxData[IFX_CFG_SHELL_CMD_LINE_SIZE + 1];
Ifx_SizeT count = IFX_CFG_SHELL_CMD_LINE_SIZE;
IfxStdIf_DPipe_read(&g_ascStandardInterface,rxData, &count, TIME_INFINITE);
//IfxAsclin_Asc_read(&g_asc, rxData, &count, TIME_INFINITE);
for(Ifx_SizeT i = 0; i++; i < count)
{
Ifx_Console_print("Received message:\nHex: %hhx", rxData[i]);
}
}
BR,
Jeremy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jeremy,
Thanks for helping. Although I think I was not clear. I'm not converting the string "12.24" to hex, rather, I'm converting the floating point number to hex, which always consists of 4 bytes, which for 12.24 would be equal to the hex values: 0a d7 43 41.
But yeah, maybe I should consider sending the value as a string instead, and then handle the conversion to float on the board. I was just trying to avoid any unnecessary operations on it.