Printf with lpc1343

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Printf with lpc1343

345 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pito on Sat Jul 06 05:47:04 MST 2013
Hi, I am trying to printf from following code:
#include "LPC13xx.h"                        /* LPC13xx definitions */
#include "clkconfig.h"
#include "gpio.h"
#include "uart.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cr_section_macros.h>
#include <NXP/crp.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

// Function __write()
uint32_t __write (int iFileHandle, uint8_t *pcBuffer, uint32_t iLength)
{
//this function is writing the printf buffer to uart
 UARTSend(pcBuffer,iLength);
 return iLength;
}

int main (void) {

    int dummy;

  GPIOInit();

  UARTInit(115200);

  // Set port for LED to output (1)
  GPIOSetDir( 0, 7, 1 );  //LED

  //GPIOSetDir( 1, 6, 0 );  //Rx
  //GPIOSetDir( 1, 7, 1 );  //Tx

  dummy = 1111;

  while (1)                                /* Loop forever */
  {
      GPIOSetValue( 0, 7, 1 );
      printf("This is a Test = %d \r\n", dummy);
      GPIOSetValue( 0, 7, 0 );
      dummy ++;

  }
}
I set lib to Redlib(nohost), however I see no activity on Tx. I am uploading via uart with flashmagic, the com works fine. The lpcxpresso IDE is the latest, build for lpc1343.
Building target: LPCX1343_cmsis2_blinky.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -L"C:\MyCode\ARM\LPCxpresso\CMSISv2p00_LPC13xx\Release" -L"C:\MyCode\ARM\LPCxpresso\LPC13xx_cmsis2_Lib\Release" -Xlinker --gc-sections -Xlinker -Map=LPCX1343_cmsis2_blinky.map -mcpu=cortex-m3 -mthumb -T "LPCX1343_cmsis2_blinky_Release.ld" -o "LPCX1343_cmsis2_blinky.axf"  ./src/blinky.o ./src/cr_startup_lpc13.o ./src/timer16_int.o   -lCMSISv2p00_LPC13xx -lLPC13xx_cmsis2_Lib
Finished building target: LPCX1343_cmsis2_blinky.axf
 
make --no-print-directory post-build
Performing post-build steps
arm-none-eabi-size LPCX1343_cmsis2_blinky.axf;  arm-none-eabi-objcopy -O ihex LPCX1343_cmsis2_blinky.axf LPCX1343_cmsis2_blinky.hex ;
   text       data        bss        dec        hex    filename
  12712          8        416      13136       3350    LPCX1343_cmsis2_blinky.axf

In uart.h I've set:
#define TX_INTERRUPT        1        /* 0 if TX uses polling, 1 interrupt driven. */

Am I missing something? Thanks!
0 Kudos
Reply
2 Replies

305 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sun Jul 07 01:45:21 MST 2013
You need to be using [FONT=Courier New]__sys_write[/FONT], not [FONT=Courier New]__write[/FONT]

See:

http://support.code-red-tech.com/CodeRedWiki/UartPrintf

Regards,
CodeRedSupport
0 Kudos
Reply

305 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pito on Sat Jul 06 07:45:45 MST 2013
OK, I had to add "retarget.c" into the build instead of my __write() function above..
0 Kudos
Reply