Hi, I want to use Ulink for downloading frimware as well as the µvision 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(); #endif putstr("\n"); putstr("\n The value in hex is 0x"); puthex((byte >> 4) & 0x0F); / byte = 8 bit char value */ puthex (byte & 0x0F); }