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.
Tool/software:
I am facing problem while establishing the communication between SCI3 and SCI2 peripherals in interrupt mode. The configuration is correct, because the code is working in TMS570LC4357 evaluation board. Please help me to resolve this problem. By observing the schematic I got to know that there are no resistors or capacitor's or IC's in between respective micro controller pins and IO pins. Here is my code:
/** @file HL_sys_main.c
* @brief Application main file
* @date 11-Dec-2018
* @version 04.07.01
*
* This file contains an empty main function,
* which can be used for the application.
*/
/*
* Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* USER CODE BEGIN (0) */
/* USER CODE END */
/* Include Files */
#include "HL_sys_common.h"
/* USER CODE BEGIN (1) */
#include "HL_sys_core.h"
#include "HL_system.h"
#include "HL_sci.h"
#include "HL_gio.h"
#define UART1 (sciREG1)
#define UART2 (sciREG2)
#define UART3 (sciREG3)
#define UART4 (sciREG4)
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
uint8 u8uart1_temp = 0u;
uint8 u8uart1_buf[120] = {0u};
uint8 u8uart1_buf_size = 0u;
uint8 u8uart2_temp = 0u;
uint8 u8uart2_buf[120] = {0u};
uint8 u8uart2_buf_size = 0u;
uint8 u8uart3_temp = 0u;
uint8 u8uart3_buf[120] = {0u};
uint8 u8uart3_buf_size = 0u;
uint8 u8uart4_temp = 0u;
uint8 u8uart4_buf[120] = {0u};
uint8 u8uart4_buf_size = 0u;
void sciDisplayText(sciBASE_t *sci, uint8 *text,uint32 length);
void main(void);
/* USER CODE END */
void main(void)
{
/* USER CODE BEGIN (3) */
sciInit();
gioInit();
_enable_IRQ();
_enable_interrupt_();
sciEnableNotification((sciBASE_t *)UART1,(uint32)SCI_RX_INT);
sciReceive((sciBASE_t *)UART1,1U,(uint8*)&u8uart1_temp);
sciEnableNotification((sciBASE_t *)UART2,(uint32)SCI_RX_INT);
sciReceive((sciBASE_t *)UART2,1U,(uint8*)&u8uart2_temp);
sciEnableNotification((sciBASE_t *)UART3,(uint32)SCI_RX_INT);
sciReceive((sciBASE_t *)UART3,1U,(uint8*)&u8uart3_temp);
sciEnableNotification((sciBASE_t *)UART4,(uint32)SCI_RX_INT);
sciReceive((sciBASE_t *)UART4,1U,(uint8*)&u8uart4_temp);
while(1)
{
if(u8uart1_buf_size != 0u)
{
sciDisplayText((sciBASE_t*)(UART1),&u8uart1_buf[0],u8uart1_buf_size);
u8uart1_buf_size= 0u;
uint8 arr[3] = {0x01u,0x02u,0x03u};
sciDisplayText((sciBASE_t*)(UART2),&arr[3],1u);
sciDisplayText((sciBASE_t*)(UART3),&arr[2],1u);
}
else
{
}
if(u8uart2_buf_size != 0u)
{
sciDisplayText((sciBASE_t*)(UART1),&u8uart2_buf[0],u8uart2_buf_size);
u8uart2_buf_size= 0u;
}
else
{
}
if(u8uart3_buf_size != 0u)
{
sciDisplayText((sciBASE_t*)(UART1),&u8uart3_buf[0],u8uart3_buf_size);
u8uart3_buf_size= 0u;
}
else
{
}
if(u8uart4_buf_size != 0u)
{
sciDisplayText((sciBASE_t*)(UART4),&u8uart4_buf[0],u8uart4_buf_size);
u8uart4_buf_size= 0u;
}
else
{
}
}
/* USER CODE END */
}
/* USER CODE BEGIN (4) */
void sciNotification(sciBASE_t *sci, uint32 flags)
{
if((sci == (sciBASE_t *)UART1))
{
if(u8uart1_buf_size == 120u) /*Checking whether buffer has enough space to receive data or not . If not, reinitializing the byte offset to zero*/
{
u8uart1_buf_size = 0u;
}
else
{
}
sciReceive((sciBASE_t *)UART1, (uint32)1u, (uint8 *)&u8uart1_temp); /*receiving data through UART peripheral 3 through interrupt*/
u8uart1_buf[u8uart1_buf_size] = u8uart1_temp; /*Loading the received data into the buffer*/
u8uart1_buf_size++; /*Incrementing byte offset data to load next data */
}
else if((sci == (sciBASE_t *)UART2))
{
if(u8uart2_buf_size == 120u) /*Checking whether buffer has enough space to receive data or not . If not, reinitializing the byte offset to zero*/
{
u8uart2_buf_size = 0u;
}
else
{
}
sciReceive((sciBASE_t *)UART2, (uint32)1u, (uint8 *)&u8uart2_temp); /*receiving data through UART peripheral 3 through interrupt*/
u8uart2_buf[u8uart2_buf_size] = u8uart2_temp; /*Loading the received data into the buffer*/
u8uart2_buf_size++; /*Incrementing byte offset data to load next data */
}
else if((sci == (sciBASE_t *)UART3))
{
if(u8uart3_buf_size == 120u) /*Checking whether buffer has enough space to receive data or not . If not, reinitializing the byte offset to zero*/
{
u8uart3_buf_size = 0u;
}
else
{
}
sciReceive((sciBASE_t *)UART3, (uint32)1u, (uint8 *)&u8uart3_temp); /*receiving data through UART peripheral 3 through interrupt*/
u8uart3_buf[u8uart3_buf_size] = u8uart3_temp; /*Loading the received data into the buffer*/
u8uart3_buf_size++; /*Incrementing byte offset data to load next data */
}
else if((sci == (sciBASE_t *)UART4))
{
if(u8uart4_buf_size == 120u) /*Checking whether buffer has enough space to receive data or not . If not, reinitializing the byte offset to zero*/
{
u8uart4_buf_size = 0u;
}
else
{
}
sciReceive((sciBASE_t *)UART4, (uint32)1u, (uint8 *)&u8uart4_temp); /*receiving data through UART peripheral 4 through interrupt*/
u8uart4_buf[u8uart4_buf_size] = u8uart4_temp; /*Loading the received data into the buffer*/
u8uart4_buf_size++; /*Incrementing byte offset data to load next data */
}
else
{
}
}
void sciDisplayText(sciBASE_t *sci, uint8 *text,uint32 length) /*Function to send UART data*/
{
while(length--)
{
while ((sci->FLR & 0x4u) == 4u); /* wait until busy */
sciSendByte(sci,*text); /* send out text */
text++;
};
}
/* USER CODE END */
Hi Uday Kiran,
I verified your code, and the below part of the code is confusing me:
See the below highlighted buf_size variable, you are sending the data only if the buf_size variable not equal to the zero, right?
And where you are assigning some value to this variable? In the receive handler, right?
But how you can go to the receive handler without even sending a single byte? So that means this buf_size variable value will always be at zero only and no data will get transmitted, and no data will get receive right?
So please give me a clarity about what exactly you are trying to do with using the single variable buf_size to control transmit and receive?
--
Thanks & regards,
Jagadish.
Hello sir, thank you for looking into my problem. I'm actually triggering the transmit and receive data from UART2 and UART3 using UART1. I will send data through dock light to UART1(which is directly connected to USB). When I send the data through USB, the interrupt gets called and data is received by UART1 (which makes UART1_buf_size zero). It will trigger the Tx of data from UART2 to aUART3 and UART3 to UART2(which is in super while loop). I'm just having control Tx using UART1.
Actually the code worked fine in TMSLC4357 evaluation board. But it is not working in development board. Would you please help me in finding out what could be the reasons.
Thanks and regards,
Uday Kiran.
Hi Uday Kiran,
Are you shorting UART2 and UART3 on HDK board and trying to test? I mean SCI2TX with SCI3RX and vice versa?
can you please give me the pin numbers that you are shorting?
--
Thanks & regards,
Jagadish.
Hi Uday Kiran,
I found that UART2 signals in HDK board are not terminated to the any connector as per the schematic:
P4 and T5 are the UART2 signals as per the datasheet:
And in HDK they are not connected to anywhere like as shown below:
I think they gave wrong name for the pins, but these are the UART2 pins. As you can see, they are unconnected. So how you are connecting these pins with UART3 pins?
--
Thanks & regards,
Jagadish.
With pin muxing in halcogen, we can resolve that know sir. That's how I connected P4 and T5 to UART3 pins.
Thanks and regards.
Uday Kiran.
Hi Uday Kiran,
These pins are only available at P4 and T5 as per the datasheet
Now how can you connect these pins with the UART3 pins, if these pins are not terminated to the any connector on HDK board?
For example, UART2 pins are available on P4 and T5
UART3 pins are available on W3 and N2
Now how you can connect P4 and T5 with the N2 and W3, if P4 and T5 not terminated to any connector in HDK board?
--
Thanks & regards,
Jagadish.
Sir, can you please guide me in using ethernet peripheral for the same controller. I'm using ethernet for the first time. I'm getting confused to use which API's.
Hi Uday Kiran.
We have LwIP based ethernet examples:
6.1. Project 0 — Hercules Safety MCUs Documentation
Please refer above link to find out the examples link for download and integration into the project.
And also, you can find some examples in below FAQ:
--
Thanks & regards,
Jagadish.