找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2641|回复: 3
打印 上一主题 下一主题
收起左侧

STM32F103C8T6最小系统配置测试程序

[复制链接]
跳转到指定楼层
楼主
ID:596000 发表于 2019-9-29 09:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
关于STM32F103C8T6最小系统配置测试

单片机源程序如下:
  1. /#include "stm32f10x.h"

  2. unsigned char *P_RXD;//接收数据指针

  3. unsigned int Num_RXD=0;//要打印字节区位码的字节数


  4. unsigned char TxBuffer[64]={0,2,3,};//串口发送缓冲区

  5. unsigned char RxBuffer[64]; //串口接收缓冲区

  6. unsigned char Key0=0;

  7. unsigned char Key0_Value=0;

  8. unsigned char Key0_State=0;

  9. unsigned char LED0_State=0;

  10. unsigned char t;

  11. unsigned char JG;//数据比较结果


  12. void Key_Delay (void)
  13. {
  14.         unsigned int i;
  15.        
  16.         for(i=0;i<0xfff;i++);
  17.        
  18.        
  19. }




  20. void Time_Delay (void)
  21. {
  22.         unsigned int i;
  23.                 unsigned int j;
  24.        
  25.         for(i=0;i<0xfff;i++)
  26.         {
  27.                
  28.                 for(j=0;j<0xFFFF;j++);
  29.   };
  30.        
  31.        
  32. }





  33. /** @addtogroup Template_Project
  34.   * @{
  35.   */

  36. /* Private typedef -----------------------------------------------------------*/
  37. /* Private define ------------------------------------------------------------*/
  38. /* Private macro -------------------------------------------------------------*/
  39. /* Private variables ---------------------------------------------------------*/
  40. /* Private function prototypes -----------------------------------------------*/
  41. /* Private functions ---------------------------------------------------------*/



  42. /* Private function prototypes -----------------------------------------------*/

  43. //void Delay(int nCount);


  44. /**
  45.   * @brief  Main program.
  46.   * @param  None
  47.   * @retval : None
  48.   */
  49. int main(void)
  50. {
  51.   /* Setup STM32 system (clock, PLL and Flash configuration) */
  52.   SystemInit();

  53.   RCC_Configuration();

  54.   NVIC_Configuration();

  55.   GPIO_Configuration();

  56.   SysTick_init();                     //延时初始化

  57.   SPI2_Init();                              //初始化SPI硬件口

  58.         P_RXD=RxBuffer;//接收指针指向接收缓冲区
  59.        
  60.   USART_Configuration();  //USART1配置

  61.   TIM2_Config();                        //定时器初始化
  62.        



  63.     OLED_Init();                         //初始化OLED      
  64.           OLED_ShowString(1,0, "0.96' OLED TEST");  
  65.           OLED_ShowString(1,16,"mcudev.taobao  ");  
  66.            OLED_ShowString(1,32,"2014-06-16");  
  67.           OLED_ShowString(1,48,"ASCII: ");  
  68.           OLED_ShowString(63,48,"CODE: ");

  69.                 {
  70.                         unsigned char i;
  71.                        
  72.                         for(i=0;i<32;i++)TxBuffer[i]=i;
  73.                        
  74.     }
  75.                
  76.                 I2CWriteByte(0,TxBuffer,32); //写入长度
  77.                        
  78.                 I2CReadByte(0,RxBuffer,32);
  79.                        
  80.                 JG=Compare_Mem (TxBuffer,RxBuffer,32);
  81.                
  82.                 if(JG==0)//对Eeprom进行读写判断;
  83.                 {
  84.                         OLED_ShowString(1,32,"Eeprom--OK  ");
  85.                         }
  86.                 else
  87.                         {
  88.                                 OLED_ShowString(1,32,"Eeprom--Error  ");
  89.       }


  90.   /* Infinite loop */
  91.   while (1)
  92.   {
  93.                
  94.                 OLED_ShowChar(48,48,t,16,1);// OLED_Refresh_Gram();
  95.                
  96.                 t++;
  97.                 if(t>'~')t=' ';
  98.                
  99.                 OLED_ShowNum(103,48,t,3,16);//
  100.                
  101.    
  102.                 if(Key0_State==0xff)
  103.                 {
  104.       LED0_State=!LED0_State;
  105.                          delay_ms(300);
  106.                         Key0_State=0;
  107.      
  108.       }
  109.                
  110.                 if(LED0_State==0)
  111.                                  {
  112.                                          LED0_ON();//LED亮
  113.                                          delay_ms(200);
  114.                                          LED0_OFF();//LED灭
  115.                                          delay_ms(200);
  116.                          }
  117.                
  118.   }

  119. }




  120. #ifdef  USE_FULL_ASSERT

  121. /**
  122.   * @brief  Reports the name of the source file and the source line number
  123.   *   where the assert_param error has occurred.
  124.   * @param file: pointer to the source file name
  125.   * @param line: assert_param error line source number
  126.   * @retval : None
  127.   */
  128. void assert_failed(uint8_t* file, uint32_t line)
  129. {
  130.   /* User can add his own implementation to report the file name and line number,
  131.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  132.   /* Infinite loop */
  133.   while (1)
  134.   {


  135.    

  136.   }
  137. }
  138. #endif



  139. /**
  140.   * @}
  141.   */


  142. /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
复制代码

所有资料51hei提供下载:
STM32_OLED(C8T6).7z (177.42 KB, 下载次数: 26)



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏3 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:638930 发表于 2019-11-9 23:09 | 只看该作者
正需要这个,谢谢
回复

使用道具 举报

板凳
ID:638930 发表于 2019-11-9 23:10 | 只看该作者
谢谢分享
回复

使用道具 举报

地板
ID:638930 发表于 2019-11-18 17:37 | 只看该作者
学习一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表