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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3885|回復: 1
打印 上一主題 下一主題
收起左側

TM4C123簡易信號發生器源碼

[復制鏈接]
跳轉到指定樓層
樓主
ID:337321 發表于 2018-5-24 15:09 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
簡易信號發生器
1啟用定時器中斷,從微控制器引腳輸出占空比為x%, x kHz的方波。
其中x為你的學號后2位,當后兩位為00時,可使用學號倒數4-3位
2 同時在液晶上按如下格式顯示:
3 簡易信號發生器
4定時器m,引腳n
5Fre=x,Duty=x
6你的姓名

注:在本目錄存放整個工程項目,包括源文件、頭文件、說明等

單片機源程序如下:
  1. #include <stdint.h>
  2. #include <stdbool.h>
  3. #include <stdio.h>
  4. #include <stdarg.h>
  5. #include <string.h>

  6. #include "inc/hw_memmap.h"
  7. #include "inc/hw_types.h"
  8. #include "inc/hw_timer.h"
  9. #include "inc/hw_ints.h"
  10. #include "inc/hw_gpio.h"
  11. #include "inc/hw_i2c.h"
  12. #include "inc/hw_sysctl.h"
  13. #include "driverlib/timer.h"
  14. #include "driverlib/interrupt.h"
  15. #include "driverlib/sysctl.h"
  16. #include "driverlib/systick.h"
  17. #include "driverlib/gpio.h"
  18. #include "driverlib/pin_map.h"
  19. #include "driverlib/ssi.h"
  20. #include "driverlib/i2c.h"
  21. #include "driverlib/udma.h"
  22. #include "driverlib/fpu.h"
  23. #include "driverlib/rom.h"
  24. #include "uc1701.h"

  25. //*****************************************************************************
  26. //Attention
  27. //TM4C123 NMI unlock - To those who want to use PF0 and PD7, be reminded that these pins defaults as NMI ! ! !
  28. //
  29. //*****************************************************************************

  30. //*****************************************************************************
  31. //
  32. // The error routine that is called if the driver library encounters an error.
  33. //
  34. //*****************************************************************************
  35. #ifdef DEBUG
  36. void
  37. __error__(char *pcFilename, unsigned long ulLine)
  38. {
  39. }
  40. #endif

  41. //*****************************************************************************
  42. //
  43. // Global variables
  44. //
  45. //
  46. //
  47. //*****************************************************************************
  48. unsigned char flag;
  49. unsigned int i;
  50. //*****************************************************************************
  51. //
  52. // The interrupt application.  
  53. // Timer interrupt
  54. //
  55. //
  56. //*****************************************************************************
  57. void Timer0IntHandler(void)
  58. {
  59.     // Clear the timer interrupt
  60.     TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);


  61.         if(i<7)
  62.         GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_4, 1<<4);  // 綠LED燈:亮;
  63.    
  64.                           else
  65.                           GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_4, 0<<4);  // 綠LED燈:亮
  66.                                 
  67.                                 i=i+1;
  68.                                 if(i==60)
  69.                                         i=0;
  70.    
  71. }

  72. //*****************************************************************************
  73. char HZ[]={
  74. 0x08,0x04,0xC3,0x12,0x26,0x8A,0xA2,0xAA,0xA4,0xA3,0x22,0x26,0xEA,0x02,0x02,0x00,
  75. 0x00,0x00,0xFF,0x00,0x00,0x3F,0x24,0x24,0x24,0x3F,0x00,0x80,0xFF,0x00,0x00,0x00,/*"簡",0*/
  76. 0x00,0x00,0x00,0x00,0x7F,0xC9,0x49,0x49,0x49,0x49,0x49,0x7F,0x00,0x00,0x00,0x00,
  77. 0x00,0x08,0x04,0x42,0x23,0x12,0x8E,0x42,0x32,0x0E,0x42,0x82,0x42,0x3E,0x00,0x00,/*"易",1*/
  78. 0x00,0x80,0x60,0xF8,0x07,0x00,0x04,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x04,0x00,
  79. 0x01,0x00,0x00,0xFF,0x00,0x00,0x00,0xF9,0x49,0x49,0x49,0x49,0x49,0xF9,0x00,0x00,/*"信",2*/
  80. 0x80,0x80,0x80,0xBE,0xA2,0xA2,0xA2,0xA2,0xA2,0xA2,0xA2,0xBE,0x80,0x80,0x80,0x00,
  81. 0x00,0x00,0x00,0x06,0x05,0x04,0x04,0x04,0x44,0x84,0x44,0x3C,0x00,0x00,0x00,0x00,/*"號",3*/
  82. 0x00,0x00,0x18,0x16,0x10,0xD0,0xB8,0x97,0x90,0x90,0x90,0x92,0x94,0x10,0x00,0x00,
  83. 0x00,0x20,0x10,0x8C,0x83,0x80,0x41,0x46,0x28,0x10,0x28,0x44,0x43,0x80,0x80,0x00,/*"發",4*/
  84. 0x80,0x40,0x30,0x1E,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
  85. 0x40,0x40,0x42,0x42,0x42,0x42,0x42,0x7F,0x42,0x42,0x42,0x42,0x42,0x40,0x40,0x00,/*"生",5*/
  86. 0x80,0x80,0x9E,0x92,0x92,0x92,0x9E,0xE0,0x80,0x9E,0xB2,0xD2,0x92,0x9E,0x80,0x00,
  87. 0x08,0x08,0xF4,0x94,0x92,0x92,0xF1,0x00,0x01,0xF2,0x92,0x94,0x94,0xF8,0x08,0x00,/*"器",6*/
  88. };

  89. char HZ1[]={
  90. 0x10,0x0C,0x44,0x44,0x44,0x44,0x45,0xC6,0x44,0x44,0x44,0x44,0x44,0x14,0x0C,0x00,
  91. 0x80,0x40,0x20,0x1E,0x20,0x40,0x40,0x7F,0x44,0x44,0x44,0x44,0x44,0x40,0x40,0x00,/*"定",0*/
  92. 0x00,0xFC,0x84,0x84,0x84,0xFC,0x00,0x10,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x00,
  93. 0x00,0x3F,0x10,0x10,0x10,0x3F,0x00,0x00,0x01,0x06,0x40,0x80,0x7F,0x00,0x00,0x00,/*"時",1*/
  94. 0x80,0x80,0x9E,0x92,0x92,0x92,0x9E,0xE0,0x80,0x9E,0xB2,0xD2,0x92,0x9E,0x80,0x00,
  95. 0x08,0x08,0xF4,0x94,0x92,0x92,0xF1,0x00,0x01,0xF2,0x92,0x94,0x94,0xF8,0x08,0x00,/*"器",2*/
  96. };

  97. char HZ2[]={
  98. 0x00,0x02,0xE2,0x22,0x22,0x22,0x22,0x3E,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,
  99. 0x00,0x03,0x02,0x02,0x42,0x82,0x42,0x3E,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,/*"引",0*/
  100. 0x00,0xFE,0x22,0x22,0xFE,0x80,0x88,0xFF,0x88,0x80,0x00,0xFC,0x04,0x04,0xFC,0x00,
  101. 0x80,0x7F,0x02,0x82,0xFF,0x10,0x3C,0x13,0x18,0x30,0x00,0xFF,0x04,0x08,0x07,0x00,/*"腳",1*/

  102. };

  103. char HZ3[]={
  104. 0x00,0x04,0x44,0x44,0x44,0x44,0xFC,0x22,0x22,0x22,0x22,0x23,0x02,0x00,0x00,0x00,
  105. 0x04,0x04,0x04,0x04,0x04,0x04,0x7F,0x82,0x82,0x82,0x82,0x82,0x82,0xF2,0x00,0x00,/*"毛",0*/
  106. 0x10,0x0C,0x44,0x54,0x54,0xFC,0x55,0x56,0x54,0xFC,0x54,0x54,0x44,0x14,0x0C,0x00,
  107. 0x11,0x11,0x09,0x05,0x03,0x21,0x25,0x45,0x49,0x91,0x03,0x05,0x09,0x11,0x11,0x00,/*"寒",1*/
  108. 0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,0x00,
  109. 0x00,0x44,0x42,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x41,0x40,0x00,0x00,/*"星",2*/

  110. };
  111. void Timer1IntHandler(void)
  112. {
  113.         // Clear the timer interrupt
  114.         TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);

  115.     if(GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_6))
  116.     {
  117.         GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6, 0<<6);  // 紅LED燈:亮
  118.     }
  119.     else
  120.     {
  121.         GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6, 1<<6);  // 紅LED燈:滅
  122.     }
  123. }

  124. //*****************************************************************************
  125. //
  126. // The main application.  
  127. // Blink the led
  128. // led2-PA4
  129. //
  130. //*****************************************************************************
  131. int
  132. main(void)
  133. {
  134.     uint32_t ui32Period;
  135.           i=0;
  136.     //
  137.     // The FPU should be enabled because some compilers will use floating-
  138.     // point registers, even for non-floating-point code. If the FPU is not
  139.     // enabled this will cause a fault.  This also ensures that floating-
  140.     // point operations could be added to this application and would work
  141.     // correctly and use the hardware floating-point unit.  Finally, lazy
  142.     // stacking is enabled for interrupt handlers.  This allows floating-
  143.     // point instructions to be used within interrupt handlers, but at the
  144.     // expense of extra stack usage.
  145.     FPUEnable();
  146.     FPULazyStackingEnable();

  147.     //
  148.     // 注:下面為用PLL和不用PLL設置系統時鐘的方法
  149.     // 啟用 PLL(通過合理設置,最高可到 80MHz),設置系統時鐘為 40 MHz
  150.     SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
  151.     // 不啟用 PLL(不超過外接晶振頻率,本核心板為 16MHz),設置系統時鐘為 16 MHz
  152.     //SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
  153.    
  154.     // LED 引腳初始化
  155.     // 設置 PA4 為輸出
  156.     SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);            // 使能 GPIO A模塊
  157.     GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4);     // PA4 設置為輸出
  158.     GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,1<<4);          // 綠 LED 燈初始態:滅
  159.     // 設置 PD6 為輸出
  160.     SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);            // 使能 GPIO D模塊
  161.     GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_6);     // PD6 設置為輸出
  162.     GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_6,1<<6);          // 紅 LED 燈初始態:滅
  163.     //
  164.     // Timer0 init
  165.     SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
  166.     TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
  167.     // Timer1 init
  168.     SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
  169.     TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
  170.    
  171.     //
  172.                 UC1701Init(60000);
  173.     UC1701Clear();
  174.                 UC1701ChineseDispaly(0, 1, 7,HZ);
  175.                 UC1701ChineseDispaly(1, 1, 3,HZ1);
  176.                 UC1701CharDispaly(1, 7, "0,");
  177.                 UC1701ChineseDispaly(1, 9, 2,HZ2);
  178.                 UC1701CharDispaly(1, 13, "PA4");
  179.                 UC1701CharDispaly(2, 1, "Fre=12,Duty=12");
  180.                 UC1701ChineseDispaly(3, 1, 3,HZ3);
  181.     // Timer delay period
  182.     ui32Period = (SysCtlClockGet());        // 獲取系統運行頻率,單位為 Hz
  183.     TimerLoadSet(TIMER0_BASE, TIMER_A, (ui32Period/1200000)-1);    // 設置 Timer0 溢出周期
  184.     TimerLoadSet(TIMER1_BASE, TIMER_A, ui32Period/3 -1);  // 設置 Timer1 溢出周期
  185.     //
  186.     // interrupt enable--timerxA
  187.     IntEnable(INT_TIMER0A);     //Enables a timer interrupt
  188.     //Enables individual timer interrupt sources
  189.     TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);   
  190.     IntEnable(INT_TIMER1A);     //Enables a timer interrupt
  191.     //Enables individual timer interrupt sources
  192.     TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);   

  193.         IntMasterEnable();  //Enables the processor interrupt

  194.     TimerIntRegister(TIMER0_BASE, TIMER_BOTH, Timer0IntHandler); //  Timer0 中斷服務函數入口
  195.     TimerIntRegister(TIMER1_BASE, TIMER_BOTH, Timer1IntHandler); //  Timer1 中斷服務函數入口
  196.     //
  197.     // timer0 enable--This will start the timer and interrupts
  198.     TimerEnable(TIMER0_BASE, TIMER_A);      // 使能 Timer0:TIMER_A
  199.     TimerEnable(TIMER1_BASE, TIMER_A);      // 使能 Timer1:TIMER_A
  200.    
  201.     ui32Period = SysCtlClockGet()/40000;    // 【示例】獲取系統時鐘,并 40k 分頻
  202.     SysCtlDelay(ui32Period);                // 【示例】調用系統延時函數
  203.    

  204.     while(1)    // 無限循環(死循環)
  205.     {
  206.         
  207.     }
  208. }
  209. // The end.
復制代碼

所有資料51hei提供下載:
s07-lab7B1.rar (1.76 MB, 下載次數: 11)



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

使用道具 舉報

沙發
ID:364014 發表于 2018-7-21 18:46 | 只看該作者
可以給新手做參考,寫的還不錯
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 日本xx视频免费观看 | 久久高清精品 | 欧美精品第三页 | 久草免费在线 | 拍拍无遮挡人做人爱视频免费观看 | 国产高清无av久久 | 国产精品久久久久久久久免费桃花 | 日本不卡一区二区三区在线观看 | 在线观看h视频 | 夜夜爽99久久国产综合精品女不卡 | 久草视频在线看 | 国产在线h | 色久在线 | 国产成人av在线播放 | 欧美日韩高清免费 | 欧美精品一区在线 | 欧美久久综合 | 成人免费观看男女羞羞视频 | 国产片一区二区三区 | 亚洲综合三区 | 亚洲一区二区在线视频 | 国产精品99久久久久久久vr | 精精国产xxxx视频在线播放7 | 亚洲国产精品福利 | 欧美激情精品久久久久久 | 精品国产乱码久久久久久1区2区 | 中文在线一区二区 | 在线播放中文字幕 | 天天操人人干 | 中文字幕在线观看成人 | 国产精品视频久久 | 欧美偷偷操 | 黄色一级大片在线免费看产 | 日韩在线一区二区三区 | 久久久久国产视频 | 国产精品久久久爽爽爽麻豆色哟哟 | 欧美激情视频一区二区三区免费 | 国产欧美一区二区三区久久手机版 | 91精品久久久久久久久99蜜臂 | 一区二区三区精品视频 | 99久热 |