1633 views|2 replies

421

Posts

1

Resources
The OP
 

Infineon Motor Kit EVAL-IMOTION2GO Study Notes 5 [Copy link]

This post was last edited by my student number on 2023-2-20 00:31

The previous note introduced the UART mode and software programming of T038, but when I was ready to start, I found a problem:

T038 has two pairs of serial ports, RX0/TX0 and RX1/TX1, of which TX0/RX0 is used for the debugger to communicate with the PC.

TX1/RX1 only has test points. To verify the UART function, you need to use a soldering iron to fly the wires.

To connect with the USB to serial port tool at hand, use Dupont wire to fly out the PIN19 (TX1), PIN20 (RX1), PIN25 (VSS) and PIN (VDD) signals on T038, as shown below

Connect the module to the PC and follow the previous tutorial to write the following code for debugging

#SET SCRIPT_USER_VERSION (1.00) /*Script version value should be 255.255*/
#SET SCRIPT_TASK0_EXECUTION_PERIOD (100) /*Script execution time for Task0 in mS, maximum value 65535*/
#SET SCRIPT_TASK1_EXECUTION_PERIOD (1) /*Script execution time for Task1 in 10mS, maximum value 65535*/
#SET SCRIPT_START_COMMAND (0x3) /* Start command, Task0 : Bit0, Task1 : Bit1; if bit is set, script executes after init */
#SET SCRIPT_TASK0_EXECUTION_STEP (1) /* Script Task0 step, This defines number of lines to be executed every 1mS*/
#SET SCRIPT_TASK1_EXECUTION_STEP (200) /* Script Task1 step, This defines number of lines to be executed every 10mS*/
/*********************************************************************************************************************/
int sVar0;
/*********************************************************************************************************************/
/*Task0 init function*/
Script_Task0_init()
{
sVar0=0;
}
/******************************************************************************************************************/
/*Task0 script function*/
Script_Task0()
{
sVar0 = sVar0+1;
if(sVar0<10)
{
GPIO7_OUT =0;
}
if((sVar0>10)&&(sVar0<20))
{
GPIO7_OUT =1;
}
if(sVar0>20)
{
sVar0 =0;
}
}
/******************************************************************************************************************/
/*Task1 init function*/
Script_Task1_init()
{
UART_DriverInit(1,0,0,115200,8,0,1);
UART_BufferInit(0,3,0,0,0xA5,0x5A,8,8);
}
/******************************************************************************************************************/
/*Task1 init function*/
Script_Task1()
{
const int START_TX_BYTE =0x5A;
const int LOW_BYTE_MASK =0xFF;
int checksum_rx;
int checksum_tx;
int status;
if(status & 0x0100)
{
checksum_rx =(-(0xA5 +UART_RxBuffer(0)+UART_RxBuffer(1)+UART_RxBuffer(2)))&0xFF;
if(checksum_rx ==UART_RxBuffer(3))
{
if(UART_RxBuffer(0) ==1)
{
TargetSpeed =UART_RxBuffer(1) |(UART_RxBuffer(2)<<8);
Command =1;
PFC_Command =1;
checksum_tx =(-(START_TX_BYTE+(TargetSpeed>>8)+(TargetSpeed&LOW_BYTE_MASK)+(Command&LOW_BYTE_MASK)+(PFC_Command&LOW_BYTE_MASK)))&LOW_BYTE_MASK;
UART_TxBuffer(0,TargetSpeed>>8);
UART_TxBuffer(1,TargetSpeed & LOW_BYTE_MASK);
UART_TxBuffer(2,Command & LOW_BYTE_MASK);
UART_TxBuffer(3,PFC_Command & LOW_BYTE_MASK);
UART_TxBuffer(4,0x00);
UART_TxBuffer(5,0x00);
UART_TxBuffer(6,0x00);
UART_TxBuffer(7,checksum_tx);
}
if(UART_RxBuffer(0) ==2)
{
Command =0;
PFC_Command =0;
TargetSpeed =MinSpd;
checksum_tx = (-(START_TX_BYTE + (TargetSpeed>>8)+(TargetSpeed&LOW_BYTE_MASK) +(Command&LOW_BYTE_MASK) +(PFC_Command&LOW_BYTE_MASK))) & LOW_BYTE_MASK;
UART_TxBuffer(0,TargetSpeed>>8);
UART_TxBuffer(1,TargetSpeed & LOW_BYTE_MASK);
UART_TxBuffer(2,Command & LOW_BYTE_MASK);
UART_TxBuffer(3,PFC_Command & LOW_BYTE_MASK);
UART_TxBuffer(4,0x00);
UART_TxBuffer(5,0x00);
UART_TxBuffer(6,0x00);
UART_TxBuffer(7,checksum_tx);
}
if(UART_RxBuffer(0) ==3)
{
checksum_tx = (-(START_TX_BYTE + (TargetSpeed>>8)+(TargetSpeed&LOW_BYTE_MASK) +(Command&LOW_BYTE_MASK) +(PFC_Command&LOW_BYTE_MASK))) & LOW_BYTE_MASK;
UART_TxBuffer(0,TargetSpeed>>8);
UART_TxBuffer(1,TargetSpeed & LOW_BYTE_MASK);
UART_TxBuffer(2,Command & LOW_BYTE_MASK);
UART_TxBuffer(3,PFC_Command & LOW_BYTE_MASK);
UART_TxBuffer(4,0x00);
UART_TxBuffer(5,0x00);
UART_TxBuffer(6,0x00);
UART_TxBuffer(7,checksum_tx);
}
}
else
{
UART_TxBuffer(0,checksum_tx);
UART_TxBuffer(1,0xEE);
UART_TxBuffer(2,0xEE);
UART_TxBuffer(3,checksum_tx);
UART_TxBuffer(4,0x00);
UART_TxBuffer(5,0x00);
UART_TxBuffer(6,0x00);
UART_TxBuffer(7,0x00);
}
UART_Control(0x0500);
}
}

According to the code content, select the communication serial port through the host computer, select the communication baud rate of 115200, write specific data and the development board will return the corresponding information; the actual serial port only shows data sending but no data receiving

I couldn't find a place to query the register contents in real time. I need to find more information on where and how to debug.

Latest reply

It keeps turning, I just want to see it turn.   Details Published on 2023-3-21 10:47
Personal signature君应有语,渺万里层云,千山暮雪,知向谁边?
 
 

6841

Posts

11

Resources
2
 
You are really good at doing things! Why not use a whole needle or a test clip?
 
 
 

7462

Posts

2

Resources
3
 

It keeps turning, I just want to see it turn.

Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list