eSCI not working in MPC5777c, need some application note

cancel
Showing results for 
Search instead for 
Did you mean: 

eSCI not working in MPC5777c, need some application note

532 Views
yogeshsharma
Contributor I

Hello Friends,

i am using MPC5777c with Lauterbach, trace32, EVB board. I am writing bootloader code, in that, i want to update my firmware using eSCI in Internal Flash mode. 

My current problem is eSCI is not working correctly, it is just sending 00 and stops working, while i am sending more bytes.

I had gone through the example is given "Example_MPC5777C-PinToggleStationery_v0_4-GHS714", even i had ported same code to my workspace. few of the main code i used is here below.


#define APC 0x2000
#define OBE 0x0200
#define IBE 0x0100
#define ODE 0x0020
#define SRC 0x0004
#define WPE 0x0002
#define WPS 0x0001
#define ALT0 0x0000
#define ALT1 0x0400
#define ALT2 0x0800
#define ALT3 0x0C00

#define ETPUA30_pin 144 // PCR number
#define ETPUA31_pin 145

#define LED1_pin ETPUA30_pin
#define LED2_pin ETPUA31_pin

#define PRC_SEL_CPU0 0x00
#define PRC_SEL_both 0x40
#define PRC_SEL_CPU1 0xC0

#define PRC_PRI(x) ((x)&0x0F)


volatile T_U32 GlobalCounter;
T_U8 T1_running = 0;
T_U16 background_running = 0;

int UART_initialized = 0;

void hw_init(void) {
#if defined(TURN_ON_CPU1)
#if defined(START_FROM_FLASH)
SIU.RSTVEC1.R = (unsigned long) 0xc00400 | 0x00000001;
#else
SIU.RSTVEC1.R = (unsigned long)0x40040000 | 0x00000001;
#endif /* defined(START_FROM_FLASH) */
#endif
}


void Init_eSCI_A (void)
{

SIU.PCR[89].R = 0x400; // Configure pad for primary func: TxDA
SIU.PCR[90].R = 0x400; // Configure pad for primary func: RxDA

/* note: SBR = fsys/(16 * desired baudrate) < 8191 */

eSCI_A.CR2.R = 0x2000; // module is enabled (default setting)

/* per_clk = 96MHz */
eSCI_A.BRR.B.SBR = 313; // 19200 baud, 8 bits, no parity
eSCI_A.CR1.B.TE = 1; // Tx enabled
eSCI_A.CR1.B.RE = 1; // Rx enabled

}

void TransmitData(const char * const pBuf, T_U32 cnt)
{
T_U8 j = 0; /* Dummy variable */
for (j=0; j< cnt; j++)
{ /* Loop for character string */

/* Wait for transmit data reg empty = 1 */
while (eSCI_A.IFSR1.B.TDRE == 0) {}
eSCI_A.IFSR1.R = 0x8000; /* Clear TDRE flag */
eSCI_A.SDR.B.RDTD = *(pBuf+j); /* Transmit 8 bits Data */
}
}

void ReceiveData(char *pBuf)
{
while (eSCI_A.IFSR1.B.RDRF == 0) {} /* Wait for receive data reg full = 1 */
eSCI_A.IFSR1.R = 0x2000; /* Clear RDRF flag */
*pBuf = (char)eSCI_A.SDR.B.RDTD; /* Read byte of Data*/
}

int read (int fno, void *buf, int size)
{
int count;

if (UART_initialized == 0)
{
Init_eSCI_A();
UART_initialized = 1;
}

for (count = 0; count < size; count++)
{
ReceiveData( (char *)buf + count );
}

return size;
}


int write (const void *buf, int size)
{
if (UART_initialized == 0)
{
Init_eSCI_A();
UART_initialized = 1;
}

TransmitData ((const char *)buf,size);
return size;
}

static void SIU_Init(void)
{
SIU.PCR[LED1_pin].R = ALT0 | OBE; // general purpose output
SIU.PCR[LED2_pin].R = ALT0 | OBE; // general purpose output
}

static void PIT0_Init(void)
{
/* 30: MDIS = 0 to enable clock for PITs. */
/* 31: FRZ = 1 for Timers stopped in debug mode */
PIT.MCR.R = 0x00000001;
PIT.TIMER[0].LDVAL.R = 18000000 - 1;

/* clear the TIF flag */
PIT.TIMER[0].TFLG.R = 0x00000001;

/* 30: TIE = 1 for interrupt request enabled */
/* 31: TEN = 1 for timer active */
PIT.TIMER[0].TCTRL.R = 0x00000003;
}

void PIT0_ISR(void)
{
SIU.GPDO[LED1_pin].R ^= 1;

PIT.TIMER[0].TFLG.R = 0x00000001;
}

void printff(char *buf, int size){

write ((const void *)buf,size);


}

static void Terminal_ECHO(void)
{
char ch;

if (eSCI_A.IFSR1.B.RDRF == 0)
return;
else
{
eSCI_A.IFSR1.R = 0x2000; // clear RDRF flag
ch =(unsigned char) eSCI_A.SDR.B.RDTD; // read byte of Data
switch(ch)
{
// enter
case '\n':
case '\r':
printff("\r\n",2);
break;

// other symbols
default:
printff("%c",1);
//fflush(stdout);
}
}
}


static void HW_init(void)
{
/* set round robin for all slaves */
XBAR.PORT[0].CRS.B.ARB = 1;
XBAR.PORT[1].CRS.B.ARB = 1;
XBAR.PORT[2].CRS.B.ARB = 1;
XBAR.PORT[3].CRS.B.ARB = 1;
XBAR.PORT[4].CRS.B.ARB = 1;
XBAR.PORT[6].CRS.B.ARB = 1;
XBAR.PORT[7].CRS.B.ARB = 1;

/* initialize GPIOs */
SIU_Init();
}

void Interrupts_enable_Core0(void)
{
/* lower current INTC priority to start INTC interrupts */
INTC.CPR_PRC[0].B.PRI = 0;

/* enable interrupts */
asm(" wrteei 1");
}

void Interrupts_init(void)
{
/* Initialize INTC for software vector mode */
INTC.MCR.R = 0x00000000;

/* configure IVPR and IVORx offsets, also includes a trap for all core
exceptions, excluding IVOR4 exceptions which have seperate handler */
// e200zX_Interrupt_Setup();

/* Set INTC ISR vector table base address */
// INTC.IACKR_PRC[0].R = (T_U32) &IntcIsrVectorTable[0];
// INTC.IACKR_PRC[1].R = (T_U32) &IntcIsrVectorTable[0];

/* assing required peripheral priorities */
INTC.PSR[301].R = PRC_SEL_CPU0 | PRC_PRI(1); // PIT0
// INTC.PSR[303].R = PRC_SEL_CPU1 | PRC_PRI(2); // PIT2
}

int main(void) {

T_U16 counter = 0;

/* MCAL Initialization */

HW_init();

/* 1 sec periodical interrupt */
PIT0_Init();

Interrupts_init();
Interrupts_enable_Core0();

printff("This is Pi\r\n",12);
------------------------

had i made any mistak? or can i get some application note which will discribe how to use eSCI in MPC5777c.

thanks 

yogesh

Labels (1)
2 Replies

226 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, just to be sure - are you aware that eSCI is connected to UART-USB bridge and it is supposed to be used with virtual terminal on PC side?

pastedImage_1.png

Someone would expect it is UART connector on motherboard, but it is not. It is connected to USB connector J21.

226 Views
yogeshsharma
Contributor I

Thanks it is working now.

Now I am checking Receiver, it is not working. Any suggestion.

0 Kudos