Implementation of HI3531ARM debugging printf

Publisher:EnchantedWishLatest update time:2023-09-06 Source: elecfansKeywords:HI3531 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

void UART_Putc(char c)
{
    if (c == 'n')
  *(unsigned int *)(UART0_ADDR  + 0X00) =  'r';
    delay_x(0x800);
 *(unsigned int *)(UART0_ADDR  + 0X00) = c;
 
}
unsigned int val_i=0;
void UART_Print(const char *str,...)
{
    va_list unnamed_p;
    char *sval;
    unsigned int tmp=0;
    va_start( unnamed_p, str);


    while (*str)
 {
     //
     if(*str=='%')
     {
       switch(*++str)
       {
           case 'd'://Output decimal
               break;
           case 'c'://Output character
               break;
           case 's'://Output string
               for(sval = va_arg(unnamed_p,char*);*sval;sval++)
               {
                   UART_Putc(*sval);
               }
               str++;
               break;
           case 'X'://Output 16 decimal
           case ' x'://Output 16 decimal
               val_i = va_arg(unnamed_p,unsigned int);
               //
               UART_Putc('0');delay_x(0X800);
               UART_Putc('x');delay_x(0X800);
               for(i=0; i<8;i++)
               {
                   delay_x(0X800);
                   tmp = val_i>>(4*(7-i));
                   val_i = val_i&(~(0xff<<(4*(7-i))));
                   //
                   if(tmp<10)
                       UART_Putc('0'+tmp);
                   else
                       UART_Putc('A'+tmp-10);
                   //
               }
               //
               str++;
               break;
          default://output character
               break;
         
       }
     }
     //
  UART_Putc( *str++);
  
 }
}


Keywords:HI3531 Reference address:Implementation of HI3531ARM debugging printf

Previous article:A brief analysis of variable parameter functions in C language (taking the implementation of the printf() function in the Arm program as an example)
Next article:RO base and RW base in ADS1.2

Recommended ReadingLatest update time:2024-11-16 09:34

stm32 printf freezes
The default output device of the standard library function is the display. To output to the serial port or LCD, you must redefine the functions related to the output device called in the standard library function. For example: if printf is output to the serial port, the output in fputc needs to be directed to the se
[Microcontroller]
STM32 printf semihost mode
After reading the problem of printf function redirection in the usart section of Atom Brother, I tried it myself. The microcontroller can print information through the serial port, and the printf function is very convenient to use after redirection. Redirection refers to modifying the underlying function of printf s
[Microcontroller]
STM32 printf semihost mode
C51 serial port sending and receiving, printf, receiving character string
Serial port sending, receiving In while(1){printf("xxx"); delay(100); //delay function is needed here;} #include reg51.h    //stdio.h, string.h are used for printf function prototype   #include stdio.h    void delay(unsigned int z)   {       unsigned int x,y;       for(x=z;x 0;x--)           for(y=110;y 0;y--);  
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号