MSPG3507——蓝牙接收数据显示在OLED,滴答定时器延时500MS

#include "ti_msp_dl_config.h"
#include "OLED.h"
#include "stdio.h"




volatile unsigned int delay_times = 0;
 


//搭配滴答定时器实现的精确ms延时
void delay_ms(unsigned int ms) 
{
    delay_times = ms;
    while( delay_times != 0 );
}      




int a=0;
volatile uint8_t gEchoData = 0;


int main(void)
{

    uint8_t str[64];


    SYSCFG_DL_init();
    //NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);
   // DL_TimerA_startCounter(TIMER_0_INST);

     delay_ms(500) ;
    OLED_Init();
	OLED_Fill(0x00);

    NVIC_ClearPendingIRQ(UART_2_INST_INT_IRQN);                                //先清除中断,防止直接进中断
    NVIC_EnableIRQ(UART_2_INST_INT_IRQN);   






    while (1)
     {
        sprintf((char *)str, "%d", a);
        OLED_ShowStr(0,4, str,2);
      

    }
}


void UART_2_INST_IRQHandler(void)
{
    switch (DL_UART_Main_getPendingInterrupt(UART_2_INST)) {
        case DL_UART_MAIN_IIDX_RX:
            gEchoData = DL_UART_Main_receiveData(UART_2_INST);
            if (gEchoData==0x00)
            {
                    a=0;

            }

             if (gEchoData==0x01)
            {
                    a=1;

            }


             if (gEchoData==0x05)
            {
                    a=2;

            }

             if (gEchoData==0x07)
            {
                    a=3;

            }

             if (gEchoData==0x03)
            {
                    a=4;

            }


           
            break;
        default:
            break;
    }
}



void SysTick_Handler(void)
{
    if( delay_times != 0 )
    {
        delay_times--;
    }
}

配置:大部分与OLED那一篇文章相同,另外加上这些:

相关推荐
Sean_woo19983 个月前
【笔记】MSPM0G3507使用RT-Thread console——MSPM0G3507与RT_Thread(三)
笔记·mspm0g3507·rt-thread nano
幻想时刻@4 个月前
MSPM0G3507——解决printf重定向在其他位置不能用的问题(printf重定向的补充)
mspm0g3507
幻想时刻@4 个月前
MSPM0G3507——读取引脚的高低电平方法(数字信号循迹模块)
mspm0g3507
幻想时刻@5 个月前
MSPM0G3507——定时器例程讲解2——TIMX_time_mode_capture_duty_and_period
mspm0g3507
幻想时刻@5 个月前
MSPM0G3507——GPIO例程讲解1——input_capture
mspm0g3507