msp4306638系列代码
所有资料51hei提供下载:
MSP430F6638_DemoV3.0.rar
(13.2 MB, 下载次数: 35)
源码列表:
1.LED
10.PortMap
11.Timer_PWM
12.Timer_source
13.Timer_compare
14.Timer_capture
15.LCD_segment
16.MatrixKeyboard_DigitalTube
17.LCD_TFT_String
18.RTC
19.UART_RS232
2.Key_interrupt
20.UART_RS485
21.UART_IrDA
22.IIC_IrfraredThermopile&DigitalTemperature
23.TouchPad_CAP
25.UsbMessStorage
26.UsbMouse
27.SD_WriteRead
28.SD_FAT
29.LowPower
3.Key_debounce
30.ADC_Potentiometer
31.ADC_Record
32.DAC_Wave&Speaker
33.StepperMotor_DCMotor
单片机源程序如下:
- /**
- ******************************************************************************
- * @文件名 main.c
- * @作者 DY
- * @版本 V3.0
- * @摘要 步进电机测试程序
- ******************************************************************************
- * @All right reserved.
- */
- /* Includes ------------------------------------------------------------------*/
- #include <msp430f6638.h>
- #include "cd4052.h"
- #include "DRV8833.H"
- #include "ADC.h"
- #include "step_motor.h"
- #include "Timer.h"
- #include "Segment_LCD.h"
- #include "HAL_PMM.H"
- #include "HAL_UCS.H"
- extern uint16_t results[4];
- uint8_t ADC_FLAG = 0;
- uint8_t Update = 0; //数码管更新标志位
- uint16_t Pot_ADC_Result = 0 ;
- /* Private function prototypes -----------------------------------------------*/
- void Up_ClockFor_20MHZ(void);
- /* Private functions ---------------------------------------------------------*/
- /*!
- *函数功能:主函数
- *输入参数:无
- *输出参数:无
- *返回值: 无
- */
- int main(void)
- {
- uint8_t m = 0;
- WDTCTL = WDTPW + WDTHOLD; // Stop WDT
- Up_ClockFor_20MHZ(); // 时钟倍频到20MHz
- ADC_Init(); // 初始化电位器
- //LED初始化
- P4DIR |= BIT4+BIT5+BIT6;
- //段式LCD初始化
- Init_TS3A5017DR(); // Configure TS3A5017DR IN1 and IN2
- Init_lcd(); // LCD初始化
- Backlight_Enable(); // 打开背光
- LcdGo(1); // 打开液晶模块
- LCD_Clear(); // 清屏
- CD4052_Configure();
- Chanel_Configure(STEP_MOTOR);// 通道切换--->Step Motor
- DRV8833_Init();
- Step_nSleep_Enable(); // 步进电机使能
- Step_Timer_Init(); // 配置控制步进电机的定时器
- TIM_Capture_Config(); // 配置输入捕获通道
- TIM_Update_Config(); // 配置定时器,定时更新捕获的数据
- __bis_SR_register(GIE); // 使能中断
- while(1)
- {
- if(ADC_FLAG == 1)
- {
- for(m = 0 ; m < 4 ; m++)
- {
- Pot_ADC_Result += results[m];
- }
- Pot_ADC_Result = Pot_ADC_Result >> 2;//0~~4096
- //Set_TA0CCR0(Pot_ADC_Result);
- //TA1CCR0 = Pot_ADC_Result;
- ADC_FLAG = 0;
- }
- }//end while(1)
- }
- void Up_ClockFor_20MHZ(void)
- {
- SetVCore(PMMCOREV_3); // Set Vcore to accomodate for max. allowed system speed
- UCSCTL3 |= SELREF_2; // Set DCO FLL reference = REFO
- UCSCTL4 |= SELA_2; // Set ACLK = REFO
- Init_FLL_Settle(20000, 630); // Set system clock to max (20MHz)
- }
复制代码 |