久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 2392|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

STM32F103C8單片機(jī)GP8401 PAC調(diào)電壓_5MV分度源程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
1.這個(gè)例子是用于光學(xué)器件中,MEMS加電壓調(diào)轉(zhuǎn)鏡角度的工程例子;
2.此例中,用到的技術(shù)點(diǎn)有: STM32F103C8, 國(guó)內(nèi)先進(jìn)的調(diào)壓芯片GP8401,PWM,FLASH,USART;
3.電路圖中有使用MP2359降壓芯片(12VL轉(zhuǎn)5V),與LTC3872升壓芯片(5V轉(zhuǎn)60V),GP8401的PAC應(yīng)用;
4.供學(xué)習(xí)參考,也推薦一下,上海益客電子;

電路原理圖如下:


單片機(jī)源程序如下:
  1. /********************************* MDK-ARM Project ****************************
  2.    *   Project Name:
  3.    *   Firmware Library version: V3.5.0
  4.    *   Author:  
  5.    *   Date:  
  6.    *   Brief: (mcu--64kflash,20kram,72mhz,26IO)
  7.          *   使用內(nèi)部時(shí)鐘,64M,   APB1_PCLK1=32M                                         
  8. ******************************************************************************/

  9. //----------------------project header flie  ------------------------------------------
  10. #include "stm32f10x.h"
  11. #include "userconfig.h"
  12. //#include <string.h>



  13. //*************************  project functions  *********************************


  14. /*******************************************************************************
  15. * Function Name  :  Variables_Init(void)
  16. * Description    : This function .
  17. * Input          : None
  18. * Output         : None
  19. * Return         : None
  20. * Attention      : None
  21. *******************************************************************************/
  22. static void Variables_Init(void)
  23. { u8 cnt=0;
  24.         
  25.         GPIO_InitTypeDef GPIO_InitStructure;
  26.         
  27.   //IO口控制MEMS切換的端口初始化        
  28.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_12;
  29.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  30.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  31.   GPIO_Init(GPIOA, &GPIO_InitStructure);
  32.         GPIO_ResetBits(GPIOA,GPIO_Pin_6|GPIO_Pin_12);


  33.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0| GPIO_Pin_1;
  34.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  35.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  36.   GPIO_Init(GPIOB, &GPIO_InitStructure);
  37.         GPIO_ResetBits(GPIOB,GPIO_Pin_0|GPIO_Pin_1);        
  38.         
  39.         
  40.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3| GPIO_Pin_4| GPIO_Pin_5| GPIO_Pin_7| GPIO_Pin_8| GPIO_Pin_11;
  41.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  42.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  43.   GPIO_Init(GPIOA, &GPIO_InitStructure);
  44.         GPIO_ResetBits(GPIOA,GPIO_Pin_3|GPIO_Pin_4| GPIO_Pin_5| GPIO_Pin_7| GPIO_Pin_11);        
  45.         GPIO_SetBits(GPIOA,GPIO_Pin_8);
  46.         
  47.         
  48.          //變量初始化        
  49.         for(cnt=0;cnt<12;cnt++)        usart1_rx_buffer[cnt]=0;
  50.         usart1_rx_point=0;sign_rxn_cnt=0;
  51.         usart1_rx_count=0;
  52.         data_usart1_rx=0;
  53.         sign_rxn_usart1=0;

  54.         for(cnt=0;cnt<12;cnt++) usart1_tx_buffer[cnt]=0;
  55.         usart1_tx_point=0;
  56.         usart1_tx_count=0;
  57.         
  58.         sign_debug=0;
  59.         sign_clear_all_correct_vol=0;
  60.         sign_x_correct_vol=0;

  61.         set_vol_XZ=0;  //最高65.535V
  62.         set_vol_XF=0;
  63.         set_vol_YZ=0;
  64.         set_vol_YF=0;
  65.         current_vol_XZ=0;
  66.         current_vol_XF=0;
  67.         current_vol_YZ=0;
  68.         current_vol_YF=0;        
  69.         
  70.         current_ch=0; //開機(jī)默認(rèn)為通道0 各通道電壓為0MV        
  71.         current_xz=0;
  72.         current_xf=0;
  73.         current_yz=0;
  74.         current_yf=0;        
  75.         
  76.         
  77. //  //每次上電將在MCU的FLASH中的各通道及電數(shù)MV讀取SRAM中,以方使快速切換通道時(shí)輸出電壓到加電端子上                                
  78. //  if(read_CHx_VOLx_to_SRAMx()) ;            
  79. //        else
  80. //                {
  81. //                        usart1_tx_buffer[0]='e';
  82. //                        usart1_tx_buffer[1]='r';        
  83. //                        usart1_tx_buffer[2]='r';
  84. //                        usart1_tx_buffer[3]='o';
  85. //                        usart1_tx_buffer[4]='r';
  86. //                        usart1_tx_ptr(usart1_tx_buffer,5);//返回ERROR信息
  87. //          }
  88. //               
  89. //        
  90. //   //最大通道               
  91. //         max_ch=STMFLASH_ReadHalfWord(MAX_CH_FLASH_ADDR);               
  92. //        
  93.         
  94. //        //定時(shí)器PWM初始
  95. //        TIM_SelectOCxM(TIM4, TIM_Channel_1, TIM_OCMode_PWM1);  //初始中強(qiáng)置低后,要再重恢復(fù)到PWM
  96. //        TIM_SelectOCxM(TIM4, TIM_Channel_2, TIM_OCMode_PWM1);        
  97. //        TIM_CCxCmd(TIM4, TIM_Channel_1, TIM_CCx_Enable);
  98. //        TIM_CCxCmd(TIM4, TIM_Channel_2, TIM_CCx_Enable);

  99.         TIM_Cmd(TIM4, ENABLE);                                 //開啟PWM輸出波形

  100.         flag_mems_busy=IDLE;        
  101. }



  102. /*******************************************************************************
  103. * Function Name  : int main(void)
  104. * Description    : This function .
  105. * Input          : None
  106. * Output         : None
  107. * Return         : None
  108. * Attention      : None
  109. *******************************************************************************/
  110. int main(void)
  111. {
  112.                 //u8 i;
  113.                 //uint32_t n=0;
  114.         
  115.           MemsReset:
  116.     NVIC_Configuration();

  117.                 RCC_Configuration();   
  118.                 GPIO_Configuration();
  119.           EXTI_Configuration();
  120.                 TIM_Configuration();    //在PB.7上有上升沿時(shí),將在PB.6上產(chǎn)生一個(gè)脈沖;        
  121.                 USART_Configuration();
  122.                 USART_ClearFlag(USART1,USART_FLAG_RXNE);               
  123.     Variables_Init();//狀態(tài)初始
  124.          



  125. mems_IDLE();               
  126. TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Disable); //立即生效
  127. TIM_OC2PreloadConfig(TIM4, TIM_OCPreload_Disable); //立即生效        
  128.         
  129. while(1)
  130.         {   
  131.                 //IWDG_Feed();               
  132.                 //if(mems_ALARM );                 
  133.                 //if(!mems_RESET()) goto MemsReset;
  134.                                  
  135.                 if(sign_rxn_usart1==1)          // 標(biāo)記接收到了1幀數(shù)據(jù)
  136.                         {
  137.                                 receive_info();
  138.                                 sign_rxn_usart1=0;
  139.                                 mems_IDLE();
  140.                         }
  141.           }                                                                                
  142. }


  143. #ifdef  USE_FULL_ASSERT

  144. /*******************************************************************************
  145. * Function Name  : assert_failed(uint8_t* file, uint32_t line)
  146. * Description    : This function .Reports the name of the source file and
  147.                    the source line number where the assert_param error has
  148.                    occurred
  149. * Input          : file: pointer to the source file name
  150.                    line: assert_param error line source number
  151. * Output         : None
  152. * Return         : None
  153. * Attention      : None
  154. *******************************************************************************/
  155. void assert_failed(uint8_t* file, uint32_t line)
  156. {
  157.   /* User can add his own implementation to report the file name and line number,
  158.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  159.   /* Infinite loop */
  160.   while (1)
  161.   {
  162.   }
  163. }

  164. #endif
復(fù)制代碼

Keil5代碼下載(僅供參考):
代碼.7z (369.96 KB, 下載次數(shù): 16)


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 亚洲h在线观看 | 欧美日韩成人一区二区 | 91小视频| 国产精品1区 | 日本午夜免费福利视频 | 国产成人99久久亚洲综合精品 | 日本在线播放一区二区 | 久久久精品视频免费 | 久久精品国产99国产 | 国产精品伦一区二区三级视频 | 亚洲午夜av久久乱码 | 国产黄色大片在线免费观看 | 久久久精品一区二区三区四季av | 成人免费观看男女羞羞视频 | 国产精品777一区二区 | a级片播放 | 国产一级毛片精品完整视频版 | a级在线免费观看 | 伊人狼人影院 | 日韩精品一区二区三区视频播放 | 亚洲视频在线一区 | 台湾a级理论片在线观看 | 欧美综合视频在线 | 精品国产乱码久久久久久1区2区 | 免费一看一级毛片 | 欧美一区二区三区久久精品 | 中文字幕精品一区二区三区精品 | 国产一二区视频 | 日韩成人中文字幕 | 亚洲av毛片 | 久久国产精品视频 | 中文字幕第九页 | 91久久精品国产 | 日本精品一区二区在线观看 | 久久久久亚洲 | 欧美一级毛片久久99精品蜜桃 | 久久岛国| 奇米四色影视 | 午夜免费福利电影 | 国产精品久久网 | 欧美一级黄色免费看 |