MSP430F5529与MAX7456字符叠加模块的程序
[复制链接]
本帖最后由 fish001 于 2019-8-8 22:51 编辑
没用Keil,用的IAR。
单片机源程序如下:
#include <msp430f5529.h>
#include "SPI.h"
#include "MAX7456.h"
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long
void initClk(){
UCSCTL3 |= SELREF_2; // Set DCO FLL reference = REFO
UCSCTL4 |= SELA_2; // Set ACLK = REFO
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_5; // Select DCO range 24MHz operation
UCSCTL2 = FLLD_1 + 243; // Set DCO Multiplier for 12MHz
// (N + 1) * FLLRef = Fdco
// (243 + 1) * 32768 = 8MHz
// Set FLL Div = fDCOCLK/2
__bic_SR_register(SCG0); // Enable the FLL control loop
__delay_cycles(375000);
// Loop until XT1,XT2 & DCO fault flag is cleared
//等待起震
do{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
}
void main(){
P1DIR |= BIT0; // P1.0 set as output
WDTCTL = WDTPW + WDTHOLD;
MAX7456_Delay_mS(1000);
initClk();
initSPI();
initMAX7456();
// spiWriteReg(VM0,OSD_EN);
// Max7456_Learn_Char(uchar number, uchar *data);
MAX7456_Write_Char_XY(0x05,0x08,0x0C); //显示'B'
// MAX7456_Write_Char_XY(0x0A,0x08,0x0D); //显示'C'
MAX7456_Delay_mS(1000);
spiWriteReg(VM0,0X48); //设置为PAL 自动模式 显示OSD使能
// Max7456_Display_AllChar();
P1OUT = BIT0;
MAX7456_Delay_mS(10000);
P1OUT = 0x0000;
__bis_SR_register(LPM0_bits); // Enter LPM0
__no_operation(); // For debugger
while(1){
// spiWriteReg(VM0,0X48); //设置为PAL 自动模式 显示OSD使能
// MAX7456_Delay_mS(9000);//延时
// spiWriteReg(DMM,0X04);//清理显存
}
}
|