//*****************************************************************************
//
// MSP432 main.c template - Empty main
//
//****************************************************************************
#include "msp.h"
#include"LCD.h"
#include "stdint.h"
// !TODO: Remove this definition once the header file is updated this def.
#define CS_KEY 0x695A
// !TODO: Remove this definition once the header file is updated this def.
#define FLCTL_BANK0_RDCTL_WAIT__2 (2 << 12)
#define FLCTL_BANK1_RDCTL_WAIT__2 (2 << 12)
void error(void);
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
P1DIR |= BIT0; // P1.0 set as output
P4DIR |= BIT2 | BIT3;
P4SEL0 |= BIT2 | BIT3; // Output ACLK & MCLK
P4SEL1 &= ~(BIT2 | BIT3);
CSKEY = 0x695A; // Unlock CS module for register access
CSCTL0 = 0; // Reset tuning parameters
CSCTL0 = DCORSEL_
5; // Set DCO to 12MHz (nominal, center of 8-16MHz range)
官方例程msp432p401_cs_02.c中红色的是3
// Select ACLK = REFO, SMCLK = MCLK = DCO
CSCTL1 = SELA_2 | SELS_3 | SELM_3;
CSKEY = 0; // Lock CS module from unintended accesses
TFT_Initial();//初始化
while(1)
{
ClearScreen(0x0000);
ClearScreen(0x00ff);
ClearScreen(0xff00);
show_colour_bar(); //显示彩条
ClearScreen(0xff00);
Show_RGB (0,240,0,320,0xf800);//刷出320x240的小区域
ClearScreen(0xff00);
}
}
官方例程msp432p401_cs_02.c中红色的是3,查看头文件可看到
#define DCORSEL_0 (0x00000000) /* Nominal DCO Frequency Range (MHz): 1 to 2 */
#define DCORSEL_1 (0x00010000) /* Nominal DCO Frequency Range (MHz): 2 to 4 */
#define DCORSEL_2 (0x00020000) /* Nominal DCO Frequency Range (MHz): 4 to 8 */
#define DCORSEL_3 (0x00030000) /* Nominal DCO Frequency Range (MHz): 8 to 16 */
#define DCORSEL_4 (0x00040000) /* Nominal DCO Frequency Range (MHz): 16 to 32 */
#define DCORSEL_5 (0x00050000) /* Nominal DCO Frequency Range (MHz): 32 to 64 */
/* CSCTL0[DCORES] Bits */
#define DCORES_OFS (22) /* DCORES Offset */
#define DCORES (0x00400000) /* Enables the DCO external resistor mode */
/* CSCTL0[DCOEN] Bits */
我知道这样设置DCO是不对的,但我用示波器查看P4.3口 的主时钟时钟输出确实也达到了48m。官方的那个48M例程好像也有问题,我现在也没办法测试了
另外注意 : 我的板子昨天在我将评估板USB从电脑USB接口上取下来转接到示波器USB上供电时板子烧坏了,此时探针还接在P4.3口,也不知道是什么情况,望高人指点
本帖最后由 xiongpb 于 2015-4-24 21:13 编辑