Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Debug Communication channel

2005-05-19 by Sridhar gadda

Hi,

I want to use Ulink for downloading frimware as well as the �vision(keil) debug serial window to diplay result. I can display the string but not hex values.

my code is

#include <LPC21xx.H>#include <DebugIO.H>#include <stdio.h>void init_serial(void){  PINSEL0 |= 0x00000005;  U0LCR = 0x83;  U0DLL = 16;  /* 57600 Baud rate @ 15MHz VPB clock */  U0LCR = 0x03;}int putchar (int ch) 				/* write character to serail port */{  #ifdef DEBUG  return (__dbg_putchar(ch));  #else  if (ch == '\n')    {	   while(!(U0LSR & 0x20));		U0THR = '\r';	 }  while (!(U0LSR & 0x20));  return (U0THR = ch);  #endif}int getchar (void)               /* Read character from serial port */{  #ifdef DEBUG  return (__dbg_getkey());  #else  while(!(U0LSR & 0x01));  return (U0RBR);  #endif}void puthex (int hex){  if (hex > 9)  putchar('A' + (hex-10));  else putchar('0' + hex);}void putstr (char *p){  while(*p)    {	   putchar (*p++);	 }}int main (){  #ifndef DEBUG  init_serial();  #endifputstr("\n");putstr("\n The value in hex is 0x");puthex((byte >> 4) & 0x0F);   / byte = 8 bit char value */puthex (byte & 0x0F);}

I can see the result on Hyperterminal but on serial window of IDE. I see only my srting The Value in hex is 0x and not hex values which I want to display.

where am I doing wrong.

Please help me out.

regards,

Sridhar 
----------------------------------------------------------------------------------------------------------------------------------------
 
Debug communication channel 
----------------------------------------------------------------------------------------------------------------------------------------
 
#include "DebugIO.H"

#define DBG_PUTCHAR __asm {                 /* Macro: DBG_PUTCHAR      */ \
  __asm         CMP     R0,#0x0A            /* Check 'ch' for LF       */ \
  __asm         BNE     wwait               /* Branch if not LF        */ \
  __asm wwait0: MRC     p14,0,R1,c0,c0      /* Read DCC Control        */ \
  __asm         TST     R1,#0x02            /* Check W bit             */ \
  __asm         BNE     wwait0              /* Branch if W = 1         */ \
  __asm         MOV     R1,#0x0D            /* Insert CR Code          */ \
  __asm         MCR     p14,0,R1,c1,c0      /* Write CR to DCC         */ \
  __asm wwait:  MRC     p14,0,R1,c0,c0      /* Read DCC Control        */ \
  __asm         TST     R1,#0x02            /* Check W bit             */ \
  __asm         BNE     wwait               /* Branch if W = 1         */ \
  __asm         MCR     p14,0,R0,c1,c0      /* Write 'ch' to DCC       */ \
}
#define DBG_GETKEY  __asm {                 /* Macro: DBG_GETKEY       */ \
  __asm rwait:  MRC     p14,0,R0,c0,c0      /* Read DCC Control        */ \
  __asm         TST     R0,#0x01            /* Check R bit             */ \
  __asm         BEQ     rwait               /* Branch if R = 0         */ \
  __asm         MRC     p14,0,R0,c1,c0      /* Read from DCC           */ \
}
#define DBG_ISKEY   __asm {                 /* Macro: DBG_ISKEY        */ \
  __asm rwait:  MRC     p14,0,R0,c0,c0      /* Read DCC Control        */ \
  __asm         AND     R0,R0,#0x01         /* Mask R bit              */ \
}
#define DBG_CR2LF   __asm {                 /* Macro: DBG_CR2LF        */ \
  __asm         CMP     R0,#0x0D            /* Check for CR            */ \
  __asm         MOVEQ   R0,#0x0A            /* Replace CR with LF      */ \
}

// Write Character to Debug Channel
int __dbg_putchar (int ch) __arm {
  DBG_PUTCHAR
}
// Read Character with echo from Debug Channel
int __dbg_getchar (void) __arm {
  DBG_GETKEY
  DBG_CR2LF
  DBG_PUTCHAR
}
// Read Character from Debug Channel
int __dbg_getkey (void) __arm {
  DBG_GETKEY
}
// Check if Character is available
int __dgb_iskey (void) __arm {
  DBG_ISKEY
}

----------------------------------------------------------------------------------------------------------------------------------------
 
thanks
 
sridhar

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.