芯片复制简易信号发生器
1启用定时器中断,从微控制器引脚输出占空比为x%, x kHz的方波。
其中x为你的学号后2位,当后两位为00时,可使用学号倒数4-3位
2 同时在液晶上按如下格式显示:
3 简易信号发生器
4定时器m,引脚n
5Fre=x,Duty=x
6你的姓名
注:在本目录存放整个工程项目,包括源文件、头文件、说明等
芯片复制单片机源程序如下:
- #include <stdint.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include <string.h>
- #include "inc/hw_memmap.h"
- #include "inc/hw_types.h"
- #include "inc/hw_timer.h"
- #include "inc/hw_ints.h"
- #include "inc/hw_gpio.h"
- #include "inc/hw_i2c.h"
- #include "inc/hw_sysctl.h"
- #include "driverlib/timer.h"
- #include "driverlib/interrupt.h"
- #include "driverlib/sysctl.h"
- #include "driverlib/systick.h"
- #include "driverlib/gpio.h"
- #include "driverlib/pin_map.h"
- #include "driverlib/ssi.h"
- #include "driverlib/i2c.h"
- #include "driverlib/udma.h"
- #include "driverlib/fpu.h"
- #include "driverlib/rom.h"
- #include "uc1701.h"
- //*****************************************************************************
- //Attention
- //TM4C123 NMI unlock - To those who want to use PF0 and PD7, be reminded that these pins defaults as NMI ! ! !
- //
- //*****************************************************************************
- //*****************************************************************************
- //
- // The error routine that is called if the driver library encounters an error.
- //
- //*****************************************************************************
- #ifdef DEBUG
- void
- __error__(char *pcFilename, unsigned long ulLine)
- {
- }
- #endif
- //*****************************************************************************
- //
- // Global variables
- //
- //
- //
- //*****************************************************************************
- unsigned char flag;
- unsigned int i;
- //*****************************************************************************
- //
- // The interrupt application.
- // Timer interrupt
- //
- //
- //*****************************************************************************
- void Timer0IntHandler(void)
- {
- // Clear the timer interrupt
- TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
- if(i<7)
- GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_4, 1<<4); // 绿LED灯:亮;
-
- else
- GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_4, 0<<4); // 绿LED灯:亮
-
- i=i+1;
- if(i==60)
- i=0;
-
- }