AnsweredAssumed Answered

UART program doesnt run from Flash

Question asked by Naik on Feb 18, 2013

Hi,

 

I have written a simple code to test UART interface for ADSP-EZkit BF533 processor.

The code builds and runs successfully when I select "Executable" as the target type and run it in debug mode.

But when I select "Loader" as the target type and load it onto the Flash using Flash programmer, the code doesnt run.

Following is the code -

/*****************************************************************************
* TryPgm.c
*****************************************************************************/

#include <cdefBF533.h>
#include <ccblkfn.h>
#include <stdlib.h>

#define DIVISOR   586                

void main()
{
int get_val;

init_PLL();

init_uart();

//get_val = UART_getc();

    UART_puts("Hello Pradnya",13);

}

void init_PLL(void)
{
//PLL control, CLKIN is 38.4 //27 MHz
*pPLL_CTL = 0x1B;

//PLL DIV
*pPLL_DIV = 0x3; // SSEL is 4, which gives: SCLK of 100 MHz< 133 MHz
                        //SSEL changed to 3

}

 


void init_uart(void)
{
//Enable uart clock
   *pUART_GCTL = UCEN;

//Enable access to UART_DLL and UART_DLH
*pUART_LCR  = DLAB;

//Write baud rate to the two 8-bit DL registers
*pUART_DLL  = (DIVISOR);
*pUART_DLH  = (DIVISOR >> 8);

//Clear DLAB and set UART frame to 8 bits, no parity and 1 stop bit
*pUART_LCR = 0x03;

}

void  UART_putc(char value)
{

while(!(*pUART_LSR & THRE))
{
  //Wait
};

*pUART_THR = value;

}


char UART_getc(void)
{
char cVal;

while(!(*pUART_LSR & DR))
{
  //Wait
};

cVal = *pUART_RBR;
      
return cVal;
}


void UART_puts(char *pData,int nLen)
{
int nIndx;
  
for(nIndx=0; nIndx<nLen; nIndx++)
{
  UART_putc(*pData);
  pData++;
}
}

 


void UART_gets(char *str,int len)
{
int nCnt;

for(nCnt = 0; nCnt < len; nCnt++)
{
  str[nCnt] = UART_getc();
}
}

/****************************************************************************/

This code prints the "Hello Pradnya" on Hyperterminal when run in debug mode but not when executed from Flash.

Please help.

 

Regards,

Pradnya

Outcomes