• 模拟串口输出


      最近在调试hardfault handler输出日志信息时候获得了Vincent帮助,感谢

           

    1 void Delay_UART5(uint16_t cnt)
    2 {
    3     for(;cnt;cnt--);
    4 }
     1 //void HardFault_Handler(void)        //uart5 38400
     2 //{
     3 //    
     4 //    uint32_t addrbegin=__get_MSP() ;                    //???·?·
     5          uint32_t  addr;
     6 //    uint8_t i, j, str;
     7 //    uint16_t loopcnt=0;
     8 //    
     9 ////    USART3->CR1 &=~ (1<<7);
    10 ////    GPIOB->CRH &= 0xFFFF00FF;                    //uart 3,PB10,PB11
    11 ////    GPIOB->CRH |= 0x00004100;
    12 ////    GPIOB->BSRR |= (0x0001<<10);
    13 //
    14 //    UART5->CR1 &=~ (1<<7);
    15 //     GPIOC->CRH &= 0xFFF0FFFF;                    //uart 5,PC12TX,PD2RX
    16 //    GPIOC->CRH |= 0x10000;
    17 //    GPIOC->BSRR |= (0x0001<<12);
    18 //
    19 //    while(1)
    20 //    {
    21 //        Delay_UART5(7969);
    22 //        loopcnt++;
    23 //        GPIOC->BSRR |= (0x0001<<12);
    24 //        
    25 //        if(loopcnt > 3000)
    26 //        {
    27 //            
    28 //            addr= addrbegin+0x30;
    29 //            loopcnt=0;
    30 //            for(i=0; i<255; i++)
    31 //            {
    32 //                
    33 //                str= (*(uint8_t*) addr--);
    34 //
    35 //                if(i>250)
    36 //                    str = '
    ';
    37 //                
    38 //            //    Delay_UART5(1076*4);    //9600
    39 //            //    Delay_UART5(1076);        //38400
    40 //            //    Delay_UART5(818);
    41 //            Delay_UART5(1000);
    42 //
    43 //                GPIOC->BRR |= (0x0001<<12);
    44 //            //            Delay_UART5(1076);                            //usart end
    45 //            //         Delay_UART5(269);
    46 //            //        Delay_UART5(205);
    47 //                     Delay_UART5(260);
    48 //
    49 //                for(j=0; j<8; j++)
    50 //                {
    51 //                    if((str&(0x01<<j)))
    52 //                        GPIOC->BSRR |= (0x0001<<12);
    53 //                    else
    54 //                        GPIOC->BRR |= (0x0001<<12);
    55 //            //            Delay_UART5(1076);                            //usart end
    56 //           //          Delay_UART5(269);
    57 //                      //        Delay_UART5(205);
    58 //                     Delay_UART5(260);
    59 //                }
    60 //                GPIOC->BSRR |= (0x0001<<12);
    61 //            //        Delay_UART5(1076*2);                            //usart end
    62 //            //     Delay_UART5(538);
    63 //            //     Delay_UART5(410);
    64 //                      ;Delay_UART5(500);
    65 //            }
    66 //        }
    67 //    }
    68 //}

    会有两个问题:1,延时函数需要调节,延时要在26us,不同模块都要调

      2,进入后去SP的值时候因为变量等原因SP的地址已经改变了

  • 相关阅读:
    Merge sorted ranges
    call_once/once_flag的使用
    对‘boost::serialization::singleton_module::get_lock()’未定义的引用
    C++多线程lock_guard
    长度为0的数组—— Arrays of Length Zero
    Utunbu VLC 播放器播放本机rtp码流
    Utunbu VLC 播放器播放本机h264码流
    Declaration of non-local variable in 'for' loop
    ZFEC--Demo--C语言接口
    malloc-demo
  • 原文地址:https://www.cnblogs.com/wwjdwy/p/3818364.html
Copyright © 2020-2023  润新知