Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN
Im starting a proyect with can interruptions,
/** @file 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) */
/* Includes */
#include "system.h"
#include "spi.h"
#include "het.h"
#include "gio.h"
#include "reg_pcr.h"
#include "sys_pcr.h"
#include "sys_pmm.h"
#include "reg_vim.h"
#include "sci.h"
#include "string.h"
#include "reg_can.h"
#include "can.h"
#include "sys_common.h"
#include "sys_core.h"
#include "sys_vim.h"
#include "reg_mibspi.h"
#include "reg_can.h"
#include "adc.h"
#include "i2c.h"
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
/* 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) */
/* Globals */
typedef struct qMessage
{
uint8_t len, sciRxMessage, rxData;
uint8_t buffer[128];
} qMessage_t;
typedef struct qMessage3
{
uint32_t id;
uint8_t buffer[8];
uint8_t interface;
}xMessage3;
void sysInit(void);
void canTest(void);
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
sysInit();
canTest();
while(1);
/* USER CODE END */
return 0;
}
/* USER CODE BEGIN (4) */
void canTest()
{
// uint32_t canId;
// xMessage3 *rxCanMessage = NULL;
sciSend(scilinREG, 34, (unsigned char *)"\r\n********************************");
sciSend(scilinREG, 34, (unsigned char *)"\r\n********** CAN test **********");
sciSend(scilinREG, 34, (unsigned char *)"\r\n********************************");
sciSend(scilinREG, 2, (unsigned char *)"\r\n");
sciSend(scilinREG, 12, (unsigned char *)"\r\nDeveloper:");
sciSend(scilinREG, 24, (unsigned char *)"\r\n Marco Mecha");
sciSend(scilinREG, 2, (unsigned char *)"\r\n");
static uint8_t data[8] = {0x03, 0x0A, 0x03, 0x0A, 0x0B, 0x0C, 0x0B, 0x0A};
if (canTransmit(canREG3, canMESSAGE_BOX1, data)){
sciSend(scilinREG, 22, (unsigned char *)"\r\nData send via can: ");
sciDisplayData(scilinREG, data, 8);
sciSend(scilinREG, 2, (unsigned char *)"\r\n");
}
// while(!canIsRxMessageArrived(canREG2, canMESSAGE_BOX2) || !canIsRxMessageArrived(canREG3, canMESSAGE_BOX2));
// sciDisplayData(scilinREG, rxCanMessage->buffer, 8);
// sciSend(scilinREG, 2, (unsigned char *)"\r\n");
// sciSend(scilinREG, 2, rxCanMessage->buffer);
}
void sysInit()
{
uint8_t generic = 0;
sciInit(); //SCI initialization.
canInit(); //CAN initialization.
//Enable interrupts:
_enable_interrupt_(); //General interrupt flag.
//Enable GIO interrupt:
//Enable SCI interrupt:
sciEnableNotification(scilinREG,SCI_RX_INT); //Enable SCI Lin interrupt by Rx.
sciEnableNotification(sciREG,SCI_RX_INT); //Enable SCI interrupt by Rx.
//Enable CAN interrupt:
canEnableErrorNotification(canREG2); //Enable canREG2 interrupt.
canEnableErrorNotification(canREG3); //Enable canREG3 interrupt.
//Enable I2C interrupt:
//i2cEnableNotification(i2cREG1, I2C_RX_INT);
//i2cDisableNotification(i2cREG1, I2C_RX_INT);
sciReceive(scilinREG,1, (unsigned char *)&generic);
//sciReceive(sciREG,1, (unsigned char *)&generic); //We have to set interuptions and execute this instruction to use the SCI
//i2cReceive(i2cREG1, 1, (unsigned char *)&generic);
//sciDisableNotification(sciREG,SCI_RX_INT); //Disable SCI interrupt by Rx.
sciSend(scilinREG, 37, (unsigned char *)"Initializing system. Please wait...\r\n");
gioInit(); //GIO module initialization.
gioSetDirection(hetPORT1, 1 << 15); //Enable N2HET1[15] as output. This is the output signal to the external watch-dog.
gioSetDirection(spiPORT3, 0x11); //to set the SPI3NCS[0] to output direction. The SPI3NCS[0] is the bit0 of SPIPC1 register.
//to set the SPI3NCS[4] to output direction. The SPI3NCS[4] is the bit4 of SPIPC1 register.
gioSetDirection(mibspiPORT5, 0 <<9);
gioSetDirection(mibspiPORT1, 0 <<1);
//By default we set the GIO pins for long test as follows:
gioSetDirection(mibspiPORT1, (0 << 9)); //Set MibSPI1_CLK direction. This is the bit 9 in the SPIPC3 register.
gioSetDirection(gioPORTA, (0 << 6)); //Set GIOA[6] direction. This is the bit 6 of GIODIRA register.
gioSetDirection(mibspiPORT1, (1 << 11)); //Set MibSPI1_SOMI[0] direction. This is the bit 11 in the SPIPC3 register.
gioSetDirection(mibspiPORT1, (1 << 10)); //Set MibSPI1_SIMO[0] direction. This is the bit 10 in the SPIPC3 register.
gioSetBit(mibspiPORT1, 10, 0); //We set the GIOs as logic 0
gioSetBit(mibspiPORT1, 11, 0); //We set the GIOs as logic 0
gioSetBit(spiPORT3, 0, 1); //Disable External memories SPI communication
gioSetBit(spiPORT3, 4, 1); //Disable External memories SPI communication
sciSend(scilinREG, 27, (unsigned char *)"\t************************\r\n");
sciSend(scilinREG, 27, (unsigned char *)"\tLabOSat-02 [OBC] OS V1.0\r\n");
sciSend(scilinREG, 27, (unsigned char *)"\t************************\r\n");
sciSend(scilinREG, 1, (unsigned char *)"\n");
sciSend(scilinREG, 14, (unsigned char *)"Developers: \r\n");
sciSend(scilinREG, 30, (unsigned char *)"\t Gagliardi Leandro Luciano \r\n");
sciSend(scilinREG, 22, (unsigned char *)"\t Di Nardo Federico \r\n");
sciSend(scilinREG, 1, (unsigned char *)"\n");
}
/*********************************
* SCI interrupt service routine *
*********************************/
void sciNotification(sciBASE_t *sci, unsigned flags)
{
uint8_t *rxKey = NULL;
if(sci == scilinREG){
sciReceive(scilinREG, 1, rxKey);
sciSend(sci, sizeof(uint8_t), rxKey);
}
}
/*********************************
* CAN interrupt service routine *
*********************************/
void canMessageNotification(canBASE_t *node, uint32 messageBox)
{
xMessage3 *rxCanMessage;
while(!canIsRxMessageArrived(node, canMESSAGE_BOX2));
rxCanMessage->id = canGetID(node, messageBox);
canGetData(node, messageBox, rxCanMessage->buffer); /* copy to RAM */
sciSend(scilinREG, 22, (unsigned char *)"\r\nData reciv via can: ");
sciDisplayData(scilinREG, rxCanMessage->buffer, 8);
sciSend(scilinREG, 2, (unsigned char *)"\r\n");
}
/* USER CODE END */
Im getting as ouput in the UART
Data reciv via can: FFFFFEEAFFFFFEEA
Data send via can: 030A030A0B0C0B0A
when im expecting the results to be the same.
Running in debbug mode also doesn't show the rxCanMessage change.
I also tried using a global variable but the results where the same.
Thanks in advance, Marco Mecha
