RISC-V技术论坛
直播中

卢松涛

13年用户 626经验值
擅长:嵌入式技术
私信 关注
[经验]

【南京中科微CSM32RV20开发板试用体验】+1-GPIO口串口的使用

新建的项目有很多功能的参考用法demo 红绿蓝色LED灯
    ///----Chapter 5 GPIO Test Init ---------------------------------------------------------------------------------
    GPIO_MODE_Init(GPIOA,PIN8,GPIO_MODE_OUTPUT); //GPIO 模式
    GPIO_MODE_Init(GPIOA,PIN10,GPIO_MODE_OUTPUT); //GPIO 模式
    GPIO_MODE_Init(GPIOA,PIN12,GPIO_MODE_OUTPUT); //GPIO 模式
demo UART
   ///---- Chapter 15 UART Test Init -------------------------------------------------------------------------------
    //uint8_t upack1[20] = {0,1,2,3,4,5,6,7,8,9};
    //uint8_t upack2[20] = {0,1,2,3,4,5,6,7,8,9};
    //uint8_t upack3[20] = {0,1,2,3,4,5,6,7,8,9};
    //uint8_t upack4[20] = {10,1,2,3,4,5,6,7,8,9};

    //UART_Init_case1(UART2);//非中断模式
    //UART_Init_case1(UART3);//非中断模式
    //UART_Init_case1(UART4);//非中断模式

    UART_Init_IT_case1(UART1);//中断模式
    //UART_Init_IT_case1(UART4);//中断模式
    Interrupt_Enable(UART1_int_ID);//CLIC使能单个中断
    UART1->CTRL |= 0x00000001U;  //清除中断标志位,防止开机先进一次中断
    //Interrupt_Enable(UART4_int_ID);//CLIC使能单个中断

    SYS_Interrupt_Enable();//CLIC开总中断
    //printf("uart init:rn");

串口控制a8
GPIO_Write(GPIOA,PIN8,GPIO_RESET);
10000ms a10
GPIO_Toggle(GPIOA,PIN10); //GPIO 翻转







  1. #include "headfile.h"

  2. void mp_receive_data(uint8_t *buf, uint16_t *len)
  3. {
  4.         uint8_t rxlen = UART1_RX_CNT;
  5.         uint16_t i = 0;
  6.         *len = 0;                                //默认为0
  7.         Delay32M_ms(10);                //等待40ms,连续超过10ms没有接收到一个数据,则认为接收结束
  8.         if (rxlen == UART1_RX_CNT && rxlen) //接收到了数据,且接收完成了
  9.         {
  10.                 for (i = 0; i < rxlen; i++)
  11.                 {
  12.                         buf[i] = uart_dev.rxbuf[i];
  13.                 }
  14.                 *len = UART1_RX_CNT;        //记录本次数据长度
  15.                 UART1_RX_CNT = 0;                //清零
  16.                 uart_dev.frameok=1;                //标记完成一帧数据接收
  17. //          getData=0;  //数据接收完成,标志位清零
  18.         }
  19. }
  20. #define Max_Column        128

  21. uint8_t ReceiveBuff[RECV_LEN];
  22. int main(void)
  23. {

  24.     uint16_t rlen=0;
  25.     uart_dev.rxlen=0;
  26.     ///----System Init ---------------------------------------------------------------------------------------------
  27.     CLIC_Init();//系统中断配置
  28.     System_Clock_Init();//系统时钟初始化

  29.     ///----Chapter 3 LowPower Test Init ---------------------------------------------------------------------------------
  30.     //低功耗测功耗需要IO不能悬空
  31.     //Delay32M_ms(5000);
  32.     //LowPower_Config_case1();//所有IO设置为输入,下拉
  33.     //LowPower_Config_case2();//所有IO设置为输入,上拉

  34.     //使用外部中断唤醒
  35.     //GPIO_EXIT_Init_case1(GPIOA, PIN2);//检测高电平
  36.     //Interrupt_Level(EXIT2_int_ID, INT_LEVEL0);//CLIC设置中断抢占级别
  37.     //Interrupt_Enable(EXIT2_int_ID);//CLIC使能EXIT中断
  38.     //SYS_Interrupt_Enable();//CLIC开总中断

  39.     //配置不同低功耗模式
  40.     //System_Halt();//待机模式 halt1
  41.     //System_Sleep();//睡眠模式 halt2
  42.     //System_Powerdown();//掉电模式 powerdown1
  43.     //System_DeepPwd();//掉电模式 powerdown2

  44.     ///----Chapter 5 GPIO Test Init ---------------------------------------------------------------------------------
  45.     GPIO_MODE_Init(GPIOA,PIN8,GPIO_MODE_OUTPUT); //GPIO 模式
  46.     GPIO_MODE_Init(GPIOA,PIN10,GPIO_MODE_OUTPUT); //GPIO 模式
  47.     GPIO_MODE_Init(GPIOA,PIN12,GPIO_MODE_OUTPUT); //GPIO 模式
  48.     //GPIO_MODE_Init(GPIOA,PIN14,GPIO_MODE_OUTPUT); //GPIO 模式
  49.     //GPIO_MODE_Init(GPIOA,PIN15,GPIO_MODE_OUTPUT); //GPIO 模式

  50.     //GPIO_Write(GPIOA,PIN8,GPIO_SET); //GPIO 输出
  51.     //GPIO_Write(GPIOA,PIN10,GPIO_SET); //GPIO 输出
  52.     //GPIO_Write(GPIOA,PIN12,GPIO_SET); //GPIO 输出
  53.     //GPIO_Write(GPIOA,PIN14,GPIO_RESET); //GPIO 输出
  54.     //GPIO_Write(GPIOA,PIN15,GPIO_RESET); //GPIO 输出

  55.     //GPIO_Toggle(GPIOA,PIN15); //GPIO 翻转
  56.     //GPIO_MODE_Init(GPIOA,PIN15,GPIO_MODE_INTPUT); //GPIO 模式
  57.     for(uint8_t i=0;i<10;i++)
  58.     {
  59.         GPIO_Toggle(GPIOA,PIN8); //GPIO 翻转
  60.         Delay32M_ms(100);
  61.     }

  62.     ///---- Chapter 6 EXIT Test Init -------------------------------------------------------------------------------------
  63.     //GPIO_EXIT_Init_case1(GPIOA, PIN2);//检测高电平
  64.     //GPIO_EXIT_Init_case2(GPIOA, PIN2);//检测低电平
  65.     //GPIO_EXIT_Init_case3(GPIOA, PIN2);//检测上升沿
  66.     //GPIO_EXIT_Init_case4(GPIOA, PIN2);//检测下降沿

  67.     //Interrupt_Level(EXIT2_int_ID, INT_LEVEL0);//CLIC设置中断抢占级别
  68.     //Interrupt_Enable(EXIT2_int_ID);//CLIC使能EXIT中断

  69.     //载波检测中断
  70.     //CAW_Init();//载波检测
  71.     //Interrupt_Enable(CAW_int_ID);//CLIC使能中断

  72.     //SYS_Interrupt_Enable();//CLIC开总中断

  73.     ///---- Chapter 7 RTC Test Init --------------------------------------------------------------------------------------
  74.     //RTC_Init_case1();

  75.     ///---- Chapter 8 IWDG Test Init -------------------------------------------------------------------------------------
  76.     //IWDG_Init(9000); //配置看门狗计数值(时钟频率3K)
  77.     //Delay32M_ms(1000);
  78.     //IWDG_Start(); //启动看门狗
  79.     //IWDG_Refresh(); //喂狗

  80.     ///---- Chapter 9 timer Test Init ------------------------------------------------------------------------------------
  81.     //GPIO_MODE_Init(GPIOB,PIN11,GPIO_MODE_OUTPUT); //GPIO 模式
  82.     //GPIO_MODE_Init(GPIOA,PIN9,GPIO_MODE_OUTPUT);
  83.     //GPIO_MODE_Init(GPIOA,PIN11,GPIO_MODE_OUTPUT);
  84.     //GPIO_MODE_Init(GPIOA,PIN13,GPIO_MODE_OUTPUT);

  85.     //外设配置
  86.     //Timer1_UpCounting_Mode_Init();//向上计数
  87.         //Timer1_6StepPWM_Mode_Init();//6stepPWM输出
  88.     //Timer2_UpCounting_Mode_Init();//向上计数
  89.     //Timer2_DownCounting_Mode_Init();//向下计数
  90.     //Timer2_ExternalClock_Mode_Init();//外部时钟
  91.     //Timer2_InputCapture_Mode_Init();//输入捕获
  92.     //Timer2_PWM_InputCapture_Mode_Init();//PWM输入捕获
  93.     //Timer2_Input_XOR_Mode_Init();//输入异或
  94.     //Timer2_PWM_Mode_Init();//PWM输出
  95.     //Timer2_6StepPWM_Mode_Init();//6stepPWM输出

  96.     //设置中断优先级
  97.     //Interrupt_Level(TIMER1_updata_int_ID, INT_LEVEL1);//CLIC设置中断抢占级别

  98.     //使能外设中断
  99.     //Interrupt_Enable(TIMER1_break_int_ID);//CLIC使能中断
  100.     //Interrupt_Enable(TIMER1_updata_int_ID);//CLIC使能中断
  101.     //Interrupt_Enable(TIMER1_capture_compare_int_ID);//CLIC使能中断
  102.     //Interrupt_Enable(TIMER1_trigger_comm_int_ID);//CLIC使能中断

  103.     //Interrupt_Enable(TIMER2_break_int_ID);//CLIC使能中断
  104.     //Interrupt_Enable(TIMER2_updata_int_ID);//CLIC使能中断
  105.     //Interrupt_Enable(TIMER2_capture_compare_int_ID);//CLIC使能中断
  106.     //Interrupt_Enable(TIMER2_trigger_comm_int_ID);//CLIC使能中断

  107.     //使能系统总中断
  108.     //SYS_Interrupt_Enable();//CLIC开总中断

  109.     ///---- Chapter 10 WUP Test Init -------------------------------------------------------------------------------------
  110.     //GPIO_MODE_Init(GPIOA,PIN2,GPIO_MODE_OUTPUT);
  111.     //GPIO_MODE_Init(GPIOA,PIN3,GPIO_MODE_OUTPUT);

  112.     //WUP_Init_case1(9000);//设置中断周期,使能WUP中断
  113.     //Interrupt_Enable(WUP_int_ID);//CLIC使能中断
  114.     //SYS_Interrupt_Enable();//CLIC开总中断

  115.     //配置不同低功耗模式
  116.     //System_Halt();//待机模式 halt1
  117.     //System_Sleep();//睡眠模式 halt2
  118.     //System_Powerdown();//掉电模式 powerdown1
  119.     //System_DeepPwd();//掉电模式 powerdown2

  120.     ///---- Chapter 11 ADC Test Init -------------------------------------------------------------------------------------

  121.   

  122.     ///---- Chapter 12 I2C Test Init -------------------------------------------------------------------------------------

  123.     //I2C_Init_case2();//ready中断模式
  124.     //I2C_Init_case3();//error中断模式
  125.     //I2C_Init_case4();//ready & error中断模式

  126.     //Interrupt_Enable(I2C_ready_int_ID);//CLIC使能i2c_ready中断
  127.     //Interrupt_Enable(I2C_error_int_ID);//CLIC使能i2c_error中断
  128.     //SYS_Interrupt_Enable();//CLIC开总中断

  129.     ///---- Chapter 13 SPI1 Test Init ------------------------------------------------------------------------------------
  130.     //uint8_t sTxpack[10] = {0,1,2,3,4,5,6,7,8,9};
  131.     //uint8_t sRxpack[10] = {0,1,2,3,4,5,6,7,8,9};
  132.     //uint8_t REG_Data;

  133.     //SPI1 Init Test
  134.     //SPI_Init_case1(SPI1);//非中断模式
  135.     //SPI1_CSN_Init_case1();//CFG: CE-GPIO7,CSN-GPIO8
  136.     //SPI_Init_case2(SPI1);//中断模式
  137.     //Interrupt_Enable(SPI1_int_ID);//CLIC使能单个中断

  138.     //SPI2 Init Test
  139.     //SPI_Init_case1(SPI2);//非中断模式
  140.     //SPI2_CSN_Init_case1();//CFG: CE-GPIO7,CSN-GPIO8
  141.     //SPI_Init_case2(SPI2);//中断模式
  142.     //Interrupt_Enable(SPI2_int_ID);//CLIC使能单个中断


  143.     ///---- Chapter 15 UART Test Init -------------------------------------------------------------------------------
  144.     //uint8_t upack1[20] = {0,1,2,3,4,5,6,7,8,9};
  145.     //uint8_t upack2[20] = {0,1,2,3,4,5,6,7,8,9};
  146.     //uint8_t upack3[20] = {0,1,2,3,4,5,6,7,8,9};
  147.     //uint8_t upack4[20] = {10,1,2,3,4,5,6,7,8,9};

  148.     //UART_Init_case1(UART2);//非中断模式
  149.     //UART_Init_case1(UART3);//非中断模式
  150.     //UART_Init_case1(UART4);//非中断模式

  151.     UART_Init_IT_case1(UART1);//中断模式
  152.     //UART_Init_IT_case1(UART4);//中断模式
  153.     Interrupt_Enable(UART1_int_ID);//CLIC使能单个中断
  154.     UART1->CTRL |= 0x00000001U;  //清除中断标志位,防止开机先进一次中断
  155.     //Interrupt_Enable(UART4_int_ID);//CLIC使能单个中断

  156.     SYS_Interrupt_Enable();//CLIC开总中断
  157.     //printf("uart init:rn");

  158.     ///---- Chapter 16 LV Test Init --------------------------------------------------------------------------------------
  159.     //LV_Init_case1(12);//设置低压报警阈值
  160.     //LV_Interrupt_Enable();//使能低压报警中断
  161.     //Interrupt_Enable(LV_int_ID);//CLIC使能单个中断
  162.     //SYS_Interrupt_Enable();//CLIC开总中断

  163.     ///---- Chapter 17 RANDGEN Test Init ---------------------------------------------------------------------------------
  164.     //uint32_t rand_data;

  165.     ///---- Chapter 18 compare Test Init ---------------------------------------------------------------------------------
  166.     //COPM1_Init();//COPM1
  167.     //Interrupt_Enable(COMP1_int_ID);//CLIC使能单个中断
  168.     //COPM2_Init();//COPM2
  169.     //Interrupt_Enable(COMP2_int_ID);//CLIC使能单个中断
  170.     //COPM3_Init();//COPM3
  171.     //Interrupt_Enable(COMP3_int_ID);//CLIC使能单个中断
  172.     //SYS_Interrupt_Enable();//CLIC开总中断

  173.     ///---- Chapter 22 flash Test Init ----------------------------------------------------------------------------------
  174.     //NVR_RW_Test();//NVR read and write test
  175.     //Flash_RW_Test();

  176.     ///---- 系统总中断控制 -------------------------------------------------------------------------------------------------
  177.     //SYS_Interrupt_Enable();//CLIC开总中断
  178.     //SYS_Interrupt_Disable();//CLIC关总中断
  179.     adc_pack[0]=read_csr(mcycle);
  180.     adc_pack[1]=read_csr(mcycle);
  181.     ee_printf("nHello CSM32RV20:n");
  182.     ee_printf("mcycle:%d n",read_csr(mcycle));//比如mcycle这一CSR用于处理器运行的时钟周期计数
  183.     ee_printf("read_csr(mcycle):%d n",adc_pack[1]-adc_pack[0]);//比如mcycle这一CSR用于处理器运行的时钟周期计数
  184.     ee_printf("CMU->OSC_SR:%x n",CMU->OSC_SR );
  185.     if(CMU->OSC_SR==210 ) ee_printf("CMU->OSC_SR:210,OSC 时钟已稳定,RCOSC 时钟已稳定,:OSC 在为 MCU 提供时钟;OSC 在为外设提供时钟;   n" );
  186.     //printf("Hello CSM32RV20:rn");

  187.     ee_printf("请输入:on 或者off (开灯/关灯)rn");
  188.     uint32_t rt_tick1 = rt_tick_get();
  189.     uint32_t rt_tick2 = rt_tick_get();

  190.     Delay32M_ms(1000);
  191. //   OLED_Light();
  192. //    OLED_DrawBMP(0,0,128,8,BAD_APPLE);

  193.         while(1)
  194.         {
  195.             mp_receive_data(ReceiveBuff, &rlen);
  196.         if(uart_dev.frameok==1)  //如果接收到数据
  197.         {
  198.             ee_printf("收到数据:");

  199.             Uart_Send(UART1,(uint8_t *)ReceiveBuff,rlen);

  200.             ee_printf("rn");
  201.             uint8_t aton= (uint8_t)ReceiveBuff[0];
  202.                                 uint32_t data=0;
  203.             switch (aton) {
  204.                 case 111://"o"
  205.                      if(1==rlen) break;
  206.                      if(ReceiveBuff[1]=='n')
  207.                     {
  208.                         GPIO_Write(GPIOA,PIN8,GPIO_RESET);
  209.                         ee_printf("灯开了!rn");
  210.                     }
  211.                     else if((ReceiveBuff[1]=='f')&&(ReceiveBuff[2]=='f'))
  212.                     {
  213.                         GPIO_Write(GPIOA,PIN8,GPIO_SET);
  214.                         ee_printf("关灯了!rn");
  215.                     }
  216.                     else
  217.                     {
  218.                         ee_printf("请输入:on 或者off (开灯/关灯)rn");
  219.                     }
  220.                     break;



  221.                 default:
  222.                     break;
  223.             }






  224.            uart_dev.frameok=0;
  225.            uart_dev.rxlen=0;
  226.         }
  227.         if( rt_tick_get()%1000==0) ee_printf("time is %u s n",rt_tick_get()/1000);
  228.         if(!( rt_tick_get()- rt_tick1< 10000)){
  229.                 rt_tick1 = rt_tick_get() ;
  230.              GPIO_Toggle(GPIOB,PIN8);
  231.             GPIO_Toggle(GPIOA,PIN10); //GPIO 翻转
  232. //            ee_printf("mcycle:%u n",read_csr(mcycle));
  233.             ee_printf("rt_tick_get:%u n", rt_tick_get());
  234.             ee_printf("RTC_MTIME->mtime:%lu         ",RTC_MTIME->mtime);
  235. //            ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIME->mtime));
  236.             ee_printf("RTC_MTIME->mtime0-7B:");
  237.                for (uint8_t i = 0; i < 8; i++)
  238.                 {
  239.                        ee_printf("%x    ",_REG8(0x0200bff8UL,i));
  240.                 }

  241.             ee_printf("nRTC_MTIME->mtime:%u n",_REG32(0x0200bff8UL,4));

  242.             ee_printf("RTC_MTIMECMP->mtimecmp:%lu n",RTC_MTIMECMP->mtimecmp);
  243. //            ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIMECMP->mtimecmp));
  244.             ee_printf("->?RTC_MTIME->mtime:%p n",RTC_MTIMECMP->mtimecmp);
  245.             ee_printf("RTC_MTIMECMP->mtimecmp0-7B:");
  246.                for (uint8_t i = 0; i < 8; i++)
  247.                 {
  248.                        ee_printf("%x    ",_REG8(0x02004000UL,i));
  249.                 }

  250.             ee_printf(" n");
  251.         }
  252. //        Delay32M_ms(500);
  253.         //Delay16M_ms(500);
  254.         //Delay16M_us(500000);
  255.         //GPIO_Toggle(GPIOA,PIN15);

  256.         //printf("main:rn");

  257.         ///---- Chapter 6 EXIT test ---------------------------------------------------------------------------------
  258.         //delay16M_ms(500);
  259.         //GPIO_Toggle(GPIOA,PIN15);


  260.         ///---- Chapter 8 IWDG test ---------------------------------------------------------------------------------
  261.         //IWDG_Refresh();
  262.         //delay16M_ms(500);
  263.         //GPIO_Toggle(GPIOA,PIN15);

  264.         ///---- Chapter 9 Timer test --------------------------------------------------------------------------------
  265.         //---- soft break --------------------------------------------------------------------------------------
  266.         //delay16M_ms(100);
  267.         //TIMER2->BDTR |= 1 <<15;//BDTR[15]-MOE-主输出使能:0-关闭,1-使能
  268.         //delay16M_ms(100);
  269.         //TIMER2->EGR |= 1 <<7;//EGR[7]-BG-产生刹车事件
  270.         //---- soft COM ----------------------------------------------------------------------------------------
  271.         //delay16M_ms(100);
  272.         //TIMER2->EGR = 1 <<5;//EGR[5]-COMG-捕获/比较事件,产生控制更新
  273.         //---- generate oxr ------------------------------------------------------------------------------------
  274.         /*
  275.         Delay16M_ms(10);//1
  276.         GPIO_Write(GPIOA,PIN9,GPIO_SET);
  277.         GPIO_Write(GPIOA,PIN11,GPIO_RESET);
  278.         GPIO_Write(GPIOA,PIN13,GPIO_SET);
  279.         Delay16M_ms(10);//2
  280.         GPIO_Write(GPIOA,PIN9,GPIO_SET);
  281.         GPIO_Write(GPIOA,PIN11,GPIO_RESET);
  282.         GPIO_Write(GPIOA,PIN13,GPIO_RESET);
  283.         Delay16M_ms(10);//3
  284.         GPIO_Write(GPIOA,PIN9,GPIO_SET);
  285.         GPIO_Write(GPIOA,PIN11,GPIO_SET);
  286.         GPIO_Write(GPIOA,PIN13,GPIO_RESET);
  287.         Delay16M_ms(10);//4
  288.         GPIO_Write(GPIOA,PIN9,GPIO_RESET);
  289.         GPIO_Write(GPIOA,PIN11,GPIO_SET);
  290.         GPIO_Write(GPIOA,PIN13,GPIO_RESET);
  291.         Delay16M_ms(10);//5
  292.         GPIO_Write(GPIOA,PIN9,GPIO_RESET);
  293.         GPIO_Write(GPIOA,PIN11,GPIO_SET);
  294.         GPIO_Write(GPIOA,PIN13,GPIO_SET);
  295.         Delay16M_ms(10);//6
  296.         GPIO_Write(GPIOA,PIN9,GPIO_RESET);
  297.         GPIO_Write(GPIOA,PIN11,GPIO_RESET);
  298.         GPIO_Write(GPIOA,PIN13,GPIO_SET);
  299.         */

  300.         ///---- Chapter 11 ADC test ---------------------------------------------------------------------------------

  301.         ///---- Chapter 12 I2C test ---------------------------------------------------------------------------------
  302.         //I2C_Write(0x2d,0x55);//适用于非中断模式
  303.         //i2c_data = I2C_Read(0x2d);//适用于非中断模式
  304.         //printf("data:%xrn",i2c_data);
  305.         //I2C_Write(0x2d,0xaa);//适用于非中断模式
  306.         //i2c_data = I2C_Read(0x2d);//适用于非中断模式
  307.         //printf("data:%xrn",i2c_data);
  308.         //I2C_Write_IT(0x2d,0x55);//适用于中断模式

  309.         ///---- Chapter 13 SPI test --------------------------------------------------------------------------------
  310.         //SPI1 Test
  311.         //SPI_Transceive(SPI1,sTxpack,sRxpack,10);//非中断模式
  312.         //SPI1_RW_reg(WRITE_REG+0x05,0x53);//读写Si24R1寄存器
  313.         //REG_Data = SPI1_RW_reg(READ_REG+0x05,0);//读写Si24R1寄存器
  314.         //printf("rnREG5:%02x",REG_Data);
  315.         //delay16M_ms(500);

  316.         //SPI2 Test
  317.         //SPI_Transceive(SPI2,sTxpack,sRxpack,10);//非中断模式
  318.         //SPI2_RW_reg(WRITE_REG+0x05,0x53);//读写Si24R1寄存器
  319.         //REG_Data = SPI2_RW_reg(READ_REG+0x05,0);//读写Si24R1寄存器
  320.         //printf("rnREG5:%02x",REG_Data);
  321.         //delay16M_ms(500);

  322.         ///---- Chapter 15 UART Test ------------------------------------------------------------------------------------
  323.         //---- 非中断模式数据回环测试 -------------------------------------------------------------------------------------
  324.         //Uart_Reveive(UART1,upack1,10);//适用于非中断发送模式
  325.         //Uart_Send(UART1,upack1,10);//适用于非中断发送模式
  326.         //Uart_Reveive(UART2,upack2,10);//适用于非中断发送模式
  327.         //Uart_Send(UART2,upack2,10);//适用于非中断发送模式
  328.         //Uart_Reveive(UART3,upack3,10);//适用于非中断发送模式
  329.         //Uart_Send(UART3,upack3,10);//适用于非中断发送模式
  330.         //Uart_Reveive(UART4,upack4,10);//适用于非中断发送模式
  331.         //Uart_Send(UART4,upack4,10);//适用于非中断发送模式

  332.         //---- 中断模式数据回环测试 --------------------------------------------------------------------------------------
  333.         //UART1_putbuf(UART1_getbuf());

  334.         //---- printf测试 ----------------------------------------------------------------------------------------
  335.         //printf("Hellow-01234568789abcdefghijklmnopqrstuvwxyzrn");


  336.         ///---- Chapter 17 RANDGEN test -----------------------------------------------------------------------------
  337.         //rand_data = RAND_Get();//生成随机数
  338.         //printf("rand:0x%08x,%urn",rand_data,rand_data);
  339.         //delay16M_ms(500);


  340.         ///---- Chapter 18 COMPARE test -----------------------------------------------------------------------------
  341.         //if(COMP1->irq&0x1)
  342.         //{
  343.             //GPIO_Toggle(GPIOA,PIN15);
  344.             //COMP1->irq = 1;
  345.         //}
  346.         //delay16M_ms(10);

  347.         }

  348.   return 0;
  349. }






无标题.png
com:

Hello CSM32RV20:
mcycle:112549883
read_csr(mcycle):2
CMU->OSC_SR:d2
CMU->OSC_SR:210,OSC 时钟已稳定,RCOSC 时钟已稳定,:OSC 在为 MCU 提供时钟;OSC 在为外设提供时钟;   
请输入:on 或者off (开灯/关灯)

收到数据:

rt_tick_get:11529
RTC_MTIME->mtime:36899472         RTC_MTIME->mtime0-7B:4a    4c    33    2    0    0    0    0   
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:36934400
->?RTC_MTIME->mtime:0233b880
RTC_MTIMECMP->mtimecmp0-7B:0    3    34    2    0    0    0    0     
val:6700  avr:14062513 981.4mV   2108.0mV

time:0 day 0 hour' 0:16
rt_tick_get:21537
RTC_MTIME->mtime:68926545         RTC_MTIME->mtime0-7B:c    fd    1c    4    0    0    0    0   
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:68960000
->?RTC_MTIME->mtime:041c6480
RTC_MTIMECMP->mtimecmp0-7B:0    af    1c    4    0    0    0    0     
收到数据:on

灯开了!
rt_tick_get:61655
RTC_MTIME->mtime:197302775         RTC_MTIME->mtime0-7B:c8    dd    c2    b    0    0    0    0   
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:197337600
->?RTC_MTIME->mtime:0bc34780
RTC_MTIMECMP->mtimecmp0-7B:0    92    c3    b    0    0    0    0     
time is 63 s
收到数据:off

关灯了!

更多回帖

发帖
×
20
完善资料,
赚取积分