找回密码
 立即注册

QQ登录

只需一步,快速开始

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

基于stm32的微型掌上示波器

  [复制链接]
跳转到指定楼层
楼主

所有资料打包下载:
示波器制作资料(程序).7z (6.96 MB, 下载次数: 531)


其实本人进入芯片的世界的时间并不长,从接触51单片机到现在还不到一年,所以可以算是小白啦~想了很久,总算拿出在论坛大牛前献丑的无比勇气,写起该帖。因为制作时间很短,元器件不是很够用,所以只能做出这个只有初级功能的示波器了,只是菜鸟级程序,不建议大家做学习之用。
       我是从大二下学期开始学的51单片机,之后就对烧芯片兴趣甚浓,用51做了很多小玩意出来:例如探头式温度器、基于霍尔元件的测速器,超声波测距器,震动报警器等等。
       而进入大三,我就开始学习ARM了。当时我是看刘凯老师的视频学习STM32开始进军ARM的。我一直觉得看视频学东西容易接受,所以51单片机我也是看郭天祥的视频学习的。可能因为学了一个学期的51单片机了,有点点基础,所以学习起STM32的时候感觉轻车熟路(当然,也曾经被STM32的各种库函数搞得很痛苦)。自学STM32半个学期之后,做了两个作品,一个是新型海流发电机的叶片控制装置,一个是新型风力发电机的叶片控制装置(这两个设计都是为了参加大学生节能减排大赛做的,可以由于非实力因素被刷于校赛,这个不能多说。。)……
       好了,废话不多说,基于stm32 的微型掌上示波器——这个小作品是我大三嵌入式技术课的课程设计作品。

黑色一个独立按键是增加网格时间间隔的(后来又加了个独立按键减少网格时间间隔);
蓝色按钮是用来暂停波形的,方便观察;
再右边那两个插针是信号输入的GND和SIGNAL端;


三角波

       如上图,这个作品使用4.0寸液晶显示屏来做显示的(上图左边),而芯片是用STM32F103C8T6这一款便价STM32来做的(上图右边)。芯片是做好了的最好系统板,在某宝上网购回来的,好像二十多的样子(不算运费)。




正弦波


梯形波


锯齿波


51单片机开发板做成信号源

      如上图,因为院里面的实验室太远,我就自己用51单片机开发板自己做了个简易函数发生器。通过独立按键控制发出正弦波、矩形波、三角波、锯齿波、梯形波。
      其实单片机开发板已经是我的核心家当了!因为我学习ARM的时候并没有买ARM的开发板,而是用51开发板把程序烧录进去ARM芯片里面去……(其实零花钱都用去旅游去了。。。)



洞洞板背面(黑色的是电池盒,带电源开关)

然后板子使用洞洞板来做的,洞洞板就避免不了飞线,所以我用一块海绵封住背面的飞线,声称是为了防止灰尘干扰电路(其实是为了遮盖惨不忍睹的飞线工艺啦{:12:}{:12:})。

     唉,不过想一下我现在已经大三了,马上升大四了,这个阶段做出这个作品的水平不知道是不是已经out of date了。。当然,相比于论坛里面的各位大牛小牛们,这个作品真是小巫见大巫。。~~

      这是我第一次发帖啦~这个作品我借鉴过很多很多的例程,最后自己综合、学习、效仿、然后总结起来写的。里面的某些风格可能有些像刘凯老师的,可能有些像金点原子的,甚至有些像郭天祥的-_-b。。。仅仅做学习之用,毫无商用价值之类之用。关于版权或者知识产权之类的东西我也不太懂啦,因为是小白,所以有什么冒犯或者不合适之类的敬请原谅啦。而且程序里面有很多是废程序,只是菜鸟级程序,不建议大家做学习之用(不至于用作反面教材就好啦~haha ~)
      敬请大家指正,有什么冒犯多多包涵~~哈哈~资料接下来传上来,请看附件。

源程序:
  1. /* Includes ------------------------------------------------------------------*/
  2. #include "stm32f10x_lib.h"

  3. /* Private typedef -----------------------------------------------------------*/
  4. /* Private define ------------------------------------------------------------*/
  5. #define DAC1_DHR8R1_Address      0x40007408

  6. /* Init Structure definition */
  7. DAC_InitTypeDef            DAC_InitStructure;
  8. DMA_InitTypeDef            DMA_InitStructure;
  9. TIM_TimeBaseInitTypeDef    TIM_TimeBaseStructure;

  10. /* Private macro -------------------------------------------------------------*/
  11. /* Private variables ---------------------------------------------------------*/
  12. ErrorStatus HSEStartUpStatus;
  13. uc16 Sine12bit[32] = {2047, 2447, 2831, 3185, 3498, 3750, 3939, 4056, 4095, 4056,
  14.                       3939, 3750, 3495, 3185, 2831, 2447, 2047, 1647, 1263, 909,  
  15.                       599, 344, 155, 38, 0, 38, 155, 344, 599, 909, 1263, 1647};

  16. u32 DualSine12bit[32];
  17. u8 Idx = 0;

  18. /* Private function prototypes -----------------------------------------------*/
  19. void RCC_Configuration(void);
  20. void GPIO_Configuration(void);
  21. void NVIC_Configuration(void);
  22. void Delay(vu32 nCount);

  23. /* Private functions ---------------------------------------------------------*/

  24. /*******************************************************************************
  25. * Function Name  : main
  26. * Description    : Main program.
  27. * Input          : None
  28. * Output         : None
  29. * Return         : None
  30. *******************************************************************************/
  31. int main(void)
  32. {
  33. #ifdef DEBUG
  34.   debug();
  35. #endif

  36.   /* System Clocks Configuration */
  37.   RCC_Configuration();   

  38.   /* GPIO configuration */
  39.   GPIO_Configuration();

  40.   /* NVIC Configuration */
  41.   NVIC_Configuration();

  42.   /* TIM8 Configuration */
  43.   /* Time base configuration */
  44.   TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);  
  45.   TIM_TimeBaseStructure.TIM_Period = 0x19;           
  46.   TIM_TimeBaseStructure.TIM_Prescaler = 0x00;        
  47.   TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;     
  48.   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;   
  49.   TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);

  50.   /* TIM8 TRGO selection */
  51.   TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);

  52.   /* DAC channel1 Configuration */
  53.   DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO;
  54.   DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
  55.   DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
  56.   DAC_Init(DAC_Channel_1, &DAC_InitStructure);

  57.   /* DAC channel2 Configuration  
  58.   DAC_Init(DAC_Channel_2, &DAC_InitStructure); */

  59.   /* Fill Sine32bit table */
  60.   for (Idx= 0; Idx<32; Idx++)
  61.   {
  62.     DualSine12bit[Idx] = (Sine12bit[Idx] << 16) + (Sine12bit[Idx]);     
  63.   }

  64.   /* DMA2 channel4 configuration */
  65.   DMA_DeInit(DMA1_Channel3); //将dma的通道寄存器设为默认值
  66.   DMA_InitStructure.DMA_PeripheralBaseAddr = DAC1_DHR8R1_Address;  //定义dma外设基地址
  67.   DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&DualSine12bit;
  68.   DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;  //外设作为数据传输的目的地
  69.   DMA_InitStructure.DMA_BufferSize = 32;   //dma缓存大小   
  70.   DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外设地址寄存器不变
  71.   DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;    //内存地址寄存器 递增
  72.   DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; //外设数据宽度
  73.   DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
  74.   DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;  //工作在循环缓存模式,数据传输数目为0时,自动恢复配置初值
  75.   DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  76.   DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;  //通道未被设置成内存到内存模式,与循环模式相对
  77.   DMA_Init(DMA1_Channel3, &DMA_InitStructure); //将DMA_InitStructure中指定的参数初始化dma的通道寄存器

  78.   /* Enable DMA2 Channel4 */
  79.   DMA_Cmd(DMA1_Channel3, ENABLE);  //使能通道

  80.   /* Enable DAC Channel1 */
  81.   DAC_Cmd(DAC_Channel_1, ENABLE);
  82.   /* Enable DAC Channel2 */
  83.   DAC_Cmd(DAC_Channel_1, ENABLE);

  84.   /* Enable DMA for DAC Channel2 */
  85.   DAC_DMACmd(DAC_Channel_1, ENABLE);

  86.   /* TIM8 enable counter */
  87.   TIM_Cmd(TIM6, ENABLE);

  88.   while (1)
  89.   {
  90.   GPIO_ResetBits(GPIOA , GPIO_Pin_10);  
  91.   }
  92. }

  93. /*******************************************************************************
  94. * Function Name  : RCC_Configuration
  95. * Description    : Configures the different system clocks.
  96. * Input          : None
  97. * Output         : None
  98. * Return         : None
  99. *******************************************************************************/
  100. void RCC_Configuration(void)
  101. {   
  102.   /* RCC system reset(for debug purpose) */
  103.   RCC_DeInit();

  104.   /* Enable HSE */
  105.   RCC_HSEConfig(RCC_HSE_ON);

  106.   /* Wait till HSE is ready */
  107.   HSEStartUpStatus = RCC_WaitForHSEStartUp();

  108.   if(HSEStartUpStatus == SUCCESS)
  109.   {
  110.     /* Enable Prefetch Buffer */
  111.     FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

  112.     /* Flash 2 wait state */
  113.     FLASH_SetLatency(FLASH_Latency_2);
  114.   
  115.     /* HCLK = SYSCLK */
  116.     RCC_HCLKConfig(RCC_SYSCLK_Div1);  
  117.    
  118.     /* PCLK2 = HCLK */
  119.     RCC_PCLK2Config(RCC_HCLK_Div1);  

  120.     /* PCLK1 = HCLK/2 */
  121.     RCC_PCLK1Config(RCC_HCLK_Div2);

  122.     /* PLLCLK = 8MHz * 9 = 72 MHz */
  123.     RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_3);

  124.     /* Enable PLL */  
  125.     RCC_PLLCmd(ENABLE);

  126.     /* Wait till PLL is ready */
  127.     while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
  128.     {
  129.     }

  130.     /* Select PLL as system clock source */
  131.     RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

  132.     /* Wait till PLL is used as system clock source */
  133.     while(RCC_GetSYSCLKSource() != 0x08)
  134.     {
  135.     }
  136.   }

  137. /* Enable peripheral clocks --------------------------------------------------*/
  138.   /* DMA clock enable */
  139.   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
  140.   /* AFIO and GPIOA Periph clock enable */
  141.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA, ENABLE);
  142.   /* DAC Periph clock enable */
  143.   RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
  144.   /* TIM8 Periph clock enable */
  145.   RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
  146. }

  147. /*******************************************************************************
  148. * Function Name  : GPIO_Configuration
  149. * Description    : Configures the different GPIO ports.
  150. * Input          : None
  151. * Output         : None
  152. * Return         : None
  153. *******************************************************************************/
  154. void GPIO_Configuration(void)
  155. {
  156.   GPIO_InitTypeDef GPIO_InitStructure;

  157.   /* Configure DAC channe1 and DAC channel2 outputs pins */
  158.   GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_4 | GPIO_Pin_5|GPIO_Pin_10;
  159.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  160.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  161.   GPIO_Init(GPIOA, &GPIO_InitStructure);
  162. }

  163. /*******************************************************************************
  164. * Function Name  : NVIC_Configuration
  165. * Description    : Configures Vector Table base location.
  166. * Input          : None
  167. * Output         : None
  168. * Return         : None
  169. *******************************************************************************/
  170. void NVIC_Configuration(void)
  171. {
  172. #ifdef  VECT_TAB_RAM   
  173.   /* Set the Vector Table base location at 0x20000000 */  
  174.   NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);  
  175. #else  /* VECT_TAB_FLASH  */
  176.   /* Set the Vector Table base location at 0x08000000 */  
  177.   NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   
  178. #endif
  179. }

  180. /*******************************************************************************
  181. * Function Name  : Delay
  182. * Description    : Inserts a delay time.
  183. * Input          : nCount: specifies the delay time length.
  184. * Output         : None
  185. * Return         : None
  186. *******************************************************************************/
  187. void Delay(vu32 nCount)
  188. {
  189.   for(; nCount != 0; nCount--);
  190. }

  191. #ifdef  DEBUG
  192. /*******************************************************************************
  193. * Function Name  : assert_failed
  194. * Description    : Reports the name of the source file and the source line number
  195. *                  where the assert_param error has occurred.
  196. * Input          : - file: pointer to the source file name
  197. *                  - line: assert_param error line source number
  198. * Output         : None
  199. * Return         : None
  200. *******************************************************************************/
  201. void assert_failed(u8* file, u32 line)
  202. {  
  203.   /* User can add his own implementation to report the file name and line number,
  204.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  205.   /* Infinite loop */
  206.   while (1)
  207.   {
  208.   }
  209. }
  210. #endif
复制代码
  1. #include"tft3.5.h"
  2. #include "stm32f10x_gpio.h"
  3. //#include"陈锦熙.h"
  4. //#include "美女.h"
  5. //#include "8x16.h"
  6. //#include "GB3231.h"

  7. /*------------------------------------------------
  8.                              清屏函数
  9. ------------------------------------------------*/
  10. void ClearScreen(unsigned int bColor)
  11. {
  12. unsigned int i,j;
  13. LCD_SetPos(0,320,0,480);//
  14. for (i=0;i<480;i++)
  15.         {
  16.         
  17.            for (j=0;j<320;j++)
  18.                Write_Data_U16(bColor);

  19.         }
  20. }

  21. /*-----------------------------------------------------------------------
  22.                          写8x16点阵格式的字符
  23. -----------------------------------------------------------------------*/
  24. #include "8x16.h"
  25. void LCD_PutChar8x16(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor)
  26. {
  27. unsigned int i,j;
  28. LCD_SetPos(x,x+8-1,y,y+16-1);
  29. for(i=0; i<16;i++) {
  30.                 unsigned char m=Font8x16[c*16+i];
  31.                 for(j=0;j<8;j++) {
  32.                         if((m&0x80)==0x80) {
  33.                                 Write_Data_U16(fColor);
  34.                                 }
  35.                         else {
  36.                                 Write_Data_U16(bColor);
  37.                                 }
  38.                         m<<=1;
  39.                         }
  40.                 }
  41. }

  42. /*-----------------------------------------------------------------------
  43.                              写字符
  44. -----------------------------------------------------------------------*/
  45. void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) {

  46.                 LCD_PutChar8x16( x, y, c, fColor, bColor );
  47.         }


  48. #include "GB1616.h"        //16*16汉字字模

  49. void PutGB1616(unsigned short x, unsigned short  y, unsigned char c[2], unsigned int fColor,unsigned int bColor){
  50.         unsigned int i,j,k;

  51.         LCD_SetPos(x,  x+16-1,y, y+16-1);

  52.         for (k=0;k<64;k++) { //64标示自建汉字库中的个数,循环查询内码
  53.           if ((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1])){
  54.             for(i=0;i<32;i++) {
  55.                   unsigned short m=codeGB_16[k].Msk[i];
  56.                   for(j=0;j<8;j++) {
  57.                         if((m&0x80)==0x80) {
  58.                                 Write_Data_U16(fColor);
  59.                                 }
  60.                         else {
  61.                                 Write_Data_U16(bColor);
  62.                                 }
  63.                         m<<=1;
  64.                         }
  65.                   }
  66.                 }  
  67.           }        
  68.         }
  69. /*-----------------------------------------------------------------------
  70.                            写字符串
  71. -----------------------------------------------------------------------*/
  72. void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor) {
  73.          unsigned char l=0;
  74.         while(*s) {
  75.                 if( *s < 0x80)
  76.                     {
  77.                         LCD_PutChar(x+l*8,y,*s,fColor,bColor);
  78.                         s++;l++;
  79.                         }
  80.                 else
  81.                     {
  82.                         PutGB1616(x+l*8,y,(unsigned char*)s,fColor,bColor);
  83.                         s+=2;l+=2;
  84.                         }
  85.                 }
  86.         }


  87. /*-----------------------------------------------------------------------
  88.                          显示RGB颜色
  89. -----------------------------------------------------------------------*/
  90. void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color)
  91. {
  92.         unsigned int i,j;
  93.         LCD_SetPos(x0,x1,y0,y1);
  94.         for (i=y0;i<=y1;i++)
  95.         {
  96.            for (j=x0;j<=x1;j++)
  97.                Write_Data_U16(Color);

  98.         }

  99. }
  100. /*-----------------------------------------------------------------------
  101.                               显示彩条
  102. -----------------------------------------------------------------------*/
  103. void show_colour_bar (void)

  104. {
  105.         int V,H;
  106.         LCD_SetPos(0,320,0,480);

  107.         for(H=0;H<320;H++)
  108.         {
  109.                 for(V=0;V<60;V++)
  110.                 Write_Data_U16(0xf800);
  111.         }

  112.         for(H=0;H<320;H++)
  113.         {
  114.                 for(V=60;V<120;V++)
  115.                 Write_Data_U16(0x07e0);
  116.         }

  117.         for(H=0;H<320;H++)
  118.         {
  119.                 for(V=120;V<180;V++)
  120.                 Write_Data_U16(0x001f);
  121.         }

  122.         for(H=0;H<320;H++)
  123.         {
  124.                 for(V=180;V<240;V++)
  125.                 Write_Data_U16(0xffe0);
  126.         }

  127.         for(H=0;H<320;H++)
  128.         {
  129.                 for(V=240;V<300;V++)
  130.                 Write_Data_U16(0xf81f);
  131.         }

  132.         for(H=0;H<320;H++)
  133.         {
  134.                 for(V=300;V<360;V++)
  135.                 Write_Data_U16(0x07ff);
  136.         }

  137.         for(H=0;H<320;H++)
  138.         {
  139.                 for(V=360;V<420;V++)
  140.                 Write_Data_U16(0xffff);
  141.         }

  142.         for(H=0;H<320;H++)
  143.         {
  144.                 for(V=420;V<480;V++)
  145.                 Write_Data_U16(0x0000);
  146.         }

  147. }



  148. /*-----------------------------------------------------------------------
  149.                             写指令          8位总线
  150. -----------------------------------------------------------------------*/

  151. void LCD_Write_Command(unsigned char u)
  152. {
  153.         TFT_CS_SET(0);
  154.         TFT_RS_SET(0);

  155.         DATAOUT(u);
  156.         TFT_WR_SET(0);
  157.         TFT_WR_SET(1);


  158.         TFT_CS_SET(1);
  159. }

  160. /*-----------------------------------------------------------------------
  161.                             写数据          8位总线
  162. -----------------------------------------------------------------------*/

  163. void LCD_Write_Data(unsigned char u)
  164. {

  165.   
  166.         TFT_CS_SET(0);
  167.         TFT_RS_SET(1);

  168.         DATAOUT(u);
  169.         TFT_WR_SET(0);
  170.         TFT_WR_SET(1);


  171.         TFT_CS_SET(1);
  172. }
  173. /*-----------------------------------------------------------------------
  174.                             写16位数据
  175. -----------------------------------------------------------------------*/
  176. void  Write_Data_U16(unsigned int y)
  177. {
  178.         unsigned char m,n;
  179.         m=y>>8;
  180.         n=y;
  181.         LCD_Write_Data(m);
  182.     LCD_Write_Data(n);

  183. }
  184. /*-----------------------------------------------------------------------
  185.                              延时程序
  186. -----------------------------------------------------------------------*/
  187. void delayms(unsigned int count)
  188. {
  189.     int i,j;                                                                                
  190.     for(i=0;i<count;i++)                                                                    
  191.        {
  192.              for(j=0;j<26;j++);
  193.        }                                                                                    
  194. }


  195. /*-----------------------------------------------------------------------
  196.                           液晶初始化
  197. -----------------------------------------------------------------------*/

  198. void ILI9325_Initial(void)
  199. {
  200. //     //液晶接口初始化   
  201. //         RCC->APB2ENR|=0X0000001C;//先使能外设IO PORTA,B,C时钟
  202. //        
  203. //        GPIOA->CRL=0X33333333; //PA0-7 推挽输出
  204. //        //GPIOA->ODR|=0X00FF;//全部输出高
  205. //        GPIOB->CRH=0X33333333; //PB8-15 推挽输出
  206.         //GPIOB->ODR|=0X00FF;//全部输出高
  207.         /*GPIOB->CRL&=0X000FFFFF;//PB5-7 推挽输出
  208.         GPIOB->CRL|=0X33300000;
  209.         GPIOB->CRH&=0XFFFFFFF0;//PB8   推挽输出
  210.         GPIOB->CRH|=0X00000003;
  211.         GPIOB->ODR|=0X01E0;//5-8 输出高

  212.         GPIOC->CRL&=0XFF00FFFF;//PC4,5 推挽输出
  213.         GPIOC->CRL|=0X00330000;
  214.         GPIOC->ODR|=0X0030;//4,5 输出高         */
  215.         TFT_RST_SET(0);
  216.         delayms(20);
  217.         TFT_RST_SET(1);
  218.         delayms(200);
  219. // VCI=2.80V
  220. //************* Reset LCD Driver ****************//
  221. // Synchronization after reset
  222. LCD_Write_Command(0xFF);
  223. LCD_Write_Command(0xFF);
  224. delayms(5);
  225. LCD_Write_Command(0xFF);
  226. LCD_Write_Command(0xFF);
  227. LCD_Write_Command(0xFF);
  228. LCD_Write_Command(0xFF);
  229. delayms(10);

  230. LCD_Write_Command(0xB0);
  231. LCD_Write_Data(0x00);

  232. LCD_Write_Command(0x11);
  233. delayms(150);

  234. LCD_Write_Command(0xB3);
  235. LCD_Write_Data(0x02);
  236. LCD_Write_Data(0x00);
  237. LCD_Write_Data(0x00);
  238. LCD_Write_Data(0x00);

  239. LCD_Write_Command(0xC0);
  240. LCD_Write_Data(0x13);
  241. LCD_Write_Data(0x3B);//480
  242. LCD_Write_Data(0x00);
  243. LCD_Write_Data(0x02);
  244. LCD_Write_Data(0x00);
  245. LCD_Write_Data(0x01);
  246. LCD_Write_Data(0x00);//NW
  247. LCD_Write_Data(0x43);

  248. LCD_Write_Command(0xC1);
  249. LCD_Write_Data(0x08);
  250. LCD_Write_Data(0x16);//CLOCK
  251. LCD_Write_Data(0x08);
  252. LCD_Write_Data(0x08);

  253. LCD_Write_Command(0xC4);
  254. LCD_Write_Data(0x11);
  255. LCD_Write_Data(0x07);
  256. LCD_Write_Data(0x03);
  257. LCD_Write_Data(0x03);

  258. LCD_Write_Command(0xC6);
  259. LCD_Write_Data(0x00);

  260. LCD_Write_Command(0xC8);//GAMMA
  261. LCD_Write_Data(0x03);
  262. LCD_Write_Data(0x03);
  263. LCD_Write_Data(0x13);
  264. LCD_Write_Data(0x5C);
  265. LCD_Write_Data(0x03);
  266. LCD_Write_Data(0x07);
  267. LCD_Write_Data(0x14);
  268. LCD_Write_Data(0x08);
  269. LCD_Write_Data(0x00);
  270. LCD_Write_Data(0x21);

  271. LCD_Write_Data(0x08);
  272. LCD_Write_Data(0x14);
  273. LCD_Write_Data(0x07);
  274. LCD_Write_Data(0x53);
  275. LCD_Write_Data(0x0C);
  276. LCD_Write_Data(0x13);
  277. LCD_Write_Data(0x03);
  278. LCD_Write_Data(0x03);
  279. LCD_Write_Data(0x21);
  280. LCD_Write_Data(0x00);

  281. LCD_Write_Command(0x35);
  282. LCD_Write_Data(0x00);

  283. LCD_Write_Command(0x36);
  284. LCD_Write_Data(0x00);

  285. LCD_Write_Command(0x3A);
  286. LCD_Write_Data(0x55);

  287. LCD_Write_Command(0x44);
  288. LCD_Write_Data(0x00);
  289. LCD_Write_Data(0x01);

  290. LCD_Write_Command(0xD0);
  291. LCD_Write_Data(0x07);
  292. LCD_Write_Data(0x07);//VCI1
  293. LCD_Write_Data(0x1D);//VRH
  294. LCD_Write_Data(0x03);//BT

  295. LCD_Write_Command(0xD1);
  296. LCD_Write_Data(0x03);
  297. LCD_Write_Data(0x30);//VCM
  298. LCD_Write_Data(0x10);//VDV

  299. LCD_Write_Command(0xD2);
  300. LCD_Write_Data(0x03);
  301. LCD_Write_Data(0x14);
  302. LCD_Write_Data(0x04);

  303. LCD_Write_Command(0x29);
  304. delayms(30);

  305. LCD_Write_Command(0x2A);
  306. LCD_Write_Data(0x00);
  307. LCD_Write_Data(0x00);
  308. LCD_Write_Data(0x01);
  309. LCD_Write_Data(0x3F);//320

  310. LCD_Write_Command(0x2B);
  311. LCD_Write_Data(0x00);
  312. LCD_Write_Data(0x00);
  313. LCD_Write_Data(0x01);
  314. LCD_Write_Data(0xDF);//480

  315. LCD_Write_Command(0xB4);
  316. LCD_Write_Data(0x00);
  317. delayms(100);

  318. LCD_Write_Command(0x2C);
  319. //        Write_Cmd_Data(0x0022);//
  320.                
  321. }
  322. /*-----------------------------------------------------------------------
  323.                         设置坐标点
  324. -----------------------------------------------------------------------*/
  325. static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)
  326. {
  327. LCD_Write_Command(0x2A);
  328. Write_Data_U16(x0);
  329. Write_Data_U16(x1);
  330. //LCD_Write_Data(x0>>8);
  331. //LCD_Write_Data(x0);
  332. //LCD_Write_Data(x1>>8);
  333. //LCD_Write_Data(x1);

  334. LCD_Write_Command(0x2B);
  335. Write_Data_U16(y0);
  336. Write_Data_U16(y1);
  337. //LCD_Write_Data(y0>>8);
  338. //LCD_Write_Data(y0);
  339. //LCD_Write_Data(y1>>8);
  340. //LCD_Write_Data(y1);

  341. LCD_Write_Command(0x2C);
  342. }



  343. //void show_photo(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)
  344. //{
  345. //    unsigned int x,y; //定义液晶屏坐标
  346. //   
  347. //        LCD_SetPos(x0,x1-1,y0,y1-1);                  //必须x1-1 y1-1
  348. //    for(y=y0;y<y1;y++)                    //是否写完图片数据?  
  349. //        for(x=x0;x<x1;x++)
  350. //         {
  351. //               LCD_Write_Data(pic[2*((x1-x0)*y+x)+1]);        
  352. //        LCD_Write_Data(pic[2*((x1-x0)*y+x)]);
  353. //        //Write_Data_U16(0x0f0f);
  354. //         }                  //检测是否写到屏的边缘 160x120 其他尺寸图片请自行更改尺寸
  355. //               
  356. //}


  357. void draw_point(unsigned int x0,unsigned int y0,unsigned int wcolor)
  358. {
  359.     unsigned int x,y; //定义液晶屏坐标
  360.    
  361.         LCD_SetPos(x0,x0+1,y0,y0+1);                  //必须x1-1 y1-1
  362.     for(y=y0;y<y0+1;y++)                    //是否写完图片数据?  
  363.         for(x=x0;x<x0+1;x++)
  364.          {
  365.                          Write_Data_U16(wcolor);                          //16位颜色
  366. //               LCD_Write_Data(pic[2*((x1-x0)*y+x)+1]);          //每个格子的颜色分开了两个8进制表示
  367. //        LCD_Write_Data(pic[2*((x1-x0)*y+x)]);
  368.         //Write_Data_U16(0x0f0f);
  369.          }                  //检测是否写到屏的边缘 160x120 其他尺寸图片请自行更改尺寸
  370.                
  371. }

复制代码

0.png (56.47 KB, 下载次数: 163)

0.png

评分

参与人数 1黑币 +5 收起 理由
xinhui + 5 很给力!

查看全部评分

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

使用道具 举报

沙发
ID:214521 发表于 2017-6-27 13:32 | 只看该作者
       厉害了    必须顶
回复

使用道具 举报

板凳
ID:217617 发表于 2017-7-7 13:35 | 只看该作者
好东西,我也做过
回复

使用道具 举报

地板
ID:234278 发表于 2017-9-24 09:35 | 只看该作者
不错,回去做个试试
回复

使用道具 举报

5#
ID:147616 发表于 2017-12-25 18:41 来自手机 | 只看该作者
感谢大神的分享
回复

使用道具 举报

6#
ID:263148 发表于 2017-12-26 15:29 | 只看该作者
学习一下
回复

使用道具 举报

7#
ID:263148 发表于 2017-12-26 15:47 | 只看该作者
谢谢分享
回复

使用道具 举报

8#
ID:266618 发表于 2017-12-30 16:17 | 只看该作者
楼主,我想问下,51跟32之间具体怎么连,还有就是32跟TFT屏幕之间的连接方法,论文里写的不太全
回复

使用道具 举报

9#
ID:110649 发表于 2018-1-26 01:05 | 只看该作者
谢谢分享
回复

使用道具 举报

10#
ID:276118 发表于 2018-1-31 17:53 | 只看该作者
示波器的时基和电压幅值可以调节吗?量程可以做到多少?
回复

使用道具 举报

11#
ID:120014 发表于 2018-3-16 13:35 | 只看该作者
学习中.
回复

使用道具 举报

12#
ID:163831 发表于 2018-3-28 10:15 | 只看该作者
有没有原理图啊
回复

使用道具 举报

13#
ID:335251 发表于 2018-7-9 15:58 | 只看该作者
收藏  顶
回复

使用道具 举报

14#
ID:358434 发表于 2018-7-18 10:12 | 只看该作者
不错,学习一个
回复

使用道具 举报

15#
ID:335251 发表于 2018-10-22 19:03 | 只看该作者
666,好东西。
回复

使用道具 举报

16#
ID:399179 发表于 2018-10-23 18:51 来自手机 | 只看该作者
好厉害啊!好东西!
回复

使用道具 举报

17#
ID:427509 发表于 2018-11-16 09:17 | 只看该作者
很好,非常棒
回复

使用道具 举报

18#
ID:518078 发表于 2019-4-21 20:28 | 只看该作者
很好,非常棒
回复

使用道具 举报

19#
ID:220748 发表于 2019-5-14 20:37 | 只看该作者
真希望发原理图!!
回复

使用道具 举报

20#
ID:405102 发表于 2019-8-29 21:23 | 只看该作者
感谢学习!建议;请将电路原理图发上来。
回复

使用道具 举报

21#
ID:128989 发表于 2019-8-30 13:09 | 只看该作者
不错,学习了。
回复

使用道具 举报

22#
ID:605186 发表于 2019-8-31 14:13 来自手机 | 只看该作者
不错,准备学习
回复

使用道具 举报

23#
ID:405102 发表于 2019-8-31 21:23 | 只看该作者
谢谢楼主;很好,学习。
回复

使用道具 举报

24#
ID:681047 发表于 2020-1-5 11:18 | 只看该作者
很好的,超棒呢
回复

使用道具 举报

25#
ID:285416 发表于 2020-1-13 22:27 | 只看该作者
能用文字,大概描述一下,波形显示,是什么方法,
这部分一直不理解
回复

使用道具 举报

26#
ID:208271 发表于 2020-1-14 08:13 | 只看该作者
楼主,怎样通过51把程序下载到ARM里的???
回复

使用道具 举报

27#
ID:704139 发表于 2020-3-7 17:24 | 只看该作者
谢谢分享
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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