Hi there,
I am trying to send a specific array to my slave board and it should reply back with an acknowledgement . But i was unable to receive any information. I am attaching my code below and will also attach the data sheet of my slave board. Can someonme help me identify the issue.
/*
* Copyright (c) 2015 - 2016 , Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* All rights reserved.
*
* THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED 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 NXP OR ITS 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.
*/
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "clockMan1.h"
#include "pin_mux.h"
#if CPU_INIT_CONFIG
#include "Init_Config.h"
#endif
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#include <stdint.h>
#include <stdbool.h>
/* This example is setup to work by default with EVB. To use it with other boards
please comment the following line
*/
//#define GPIOE_PORT PTE
//#define GPIOC_PORT PTC
//#define GPIOD_PORT PTD
//#define Push_Button_Switch 4U //PTD
//#define High_Beam_Switch 11U //PTE
//#define Indicator_Left_Switch 0U //PTE
//#define Indicator_Right_Switch 1U //PTE
//#define Bat_Lock_Switch 2U //PTE
//#define Brake_Switch 9U //PTE
//#define WS_Relay 7U //PTE
//#define Ignition_Relay 8U //PTE
//#define DCU_Relay 10U //PTE
//#define Lighting_Relay 3U //PTE
//#define Bat_Lock_Relay 6u //PTC
//#define Park_Detect 7u //PTC
// UART LOCK Module command frames
uint8_t unlock_cmd[12] = {0xFF,0xFF,0x55,0xAA,0x01,0x10,0x31,0x02,0x21,0x01,0x99,0xFF};
uint8_t Read_Lock_Status[12] = {0xFF,0XFF,0x55,0xAA,0x01,0x10,0x31,0x01,0x20,0x01,0x9B,0xFF};
////////////////////////////////0xFF 0XFF 0x55 0xAA 0x01 0x10 0x31 0x01 0x20 0x01 0x9B 0xFF
uint8_t Blankarray[20];
uint32_t Timeout = 100; /* Timeout in ms for blocking operations */
uint8_t arrayindex = 0 ;
void BoardInit(void)
{
/* Initialize and configure clocks
* - Setup system clocks, dividers
* - Configure FlexCAN clock, GPIO, LPSPI
* - see clock manager component for more details
*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
/* Initialize pins
* - Init FlexCAN, LPSPI and GPIO pins
* - See PinSettings component for more info
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
}
void delay(volatile int cycles)
{
/* Delay function - do nothing for a number of cycles */
while(cycles--);
}
/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - __start (startup asm routine)
* - __init_hardware()
* - main()
* - PE_low_level_init()
* - Common_Init()
* - Peripherals_Init()
*/
int main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/
/* Do the initializations required for this application */
BoardInit();
// PINS_DRV_WritePin(GPIOE_PORT,DCU_Relay,0);
// PINS_DRV_WritePin(GPIOE_PORT,Lighting_Relay,0);
// PINS_DRV_WritePin(GPIOC_PORT,Bat_Lock_Relay,0);
LPUART_DRV_Init(INST_LPUART_LOCK, &lpuart_lock_State, &lpuart_lock_InitConfig0);
delay (100000);
while (1)
{
//if ((PTE->PDIR & (1<<2)) == 0)
//{
//LPUART_DRV_SendDataBlocking(INST_LPUART_LOCK,Read_Lock_Status,12,Timeout);
if (LPUART_DRV_SendDataBlocking(INST_LPUART_LOCK,Read_Lock_Status,12,Timeout)==STATUS_SUCCESS)
{
//LPUART_DRV_ReceiveDataBlocking(INST_LPUART_LOCK,Blankarray,12, Timeout);
if (LPUART_DRV_ReceiveDataBlocking(INST_LPUART_LOCK,Blankarray,12, Timeout)==STATUS_SUCCESS)
{
arrayindex++;
}
}
//}
//LPUART_DRV_SendData(INST_LPUART_RFID,Inventory_cmd,5);
//LPUART_DRV_ReceiveDataBlocking(INST_LPUART_LOCK,Blankarray,12, Timeout);
//LPUART_DRV_ReceiveData(INST_LPUART_LOCK,Blankarray,12);
if (Blankarray[0]==0x55 && Blankarray[1]==0xAA && Blankarray[3] ==0x31
&& Blankarray[4]==0x10 && Blankarray[5] ==0x04 )
{
arrayindex++;
}
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/