用430的SPI例程修改驱动SPI彩屏,但是刷屏实在太慢了
例程序用LFXTCLK做时钟源ACLK驱动SPI,我试着改成HFXTCLK做时钟源SMCLK驱动
但是没成功,程序卡在等待发送那里,逻辑分析仪显示一个字节都没发出来,好像时钟没给上
改了好久,还是没找到那里出问题,例程也有些不明白的地方,请大家帮忙看看
用的是FR5969 LaunchPad,自己焊了22.1184M晶振22P电容
430SPI例程:
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_PJ,GPIO_PIN4 + GPIO_PIN5,GPIO_PRIMARY_MODULE_FUNCTION);
//首先时钟引脚初始化
CS_setExternalClockSource(32768,0);
//这里貌似是为之后设置时钟有关的宏观变量
//Set DCO frequency to max DCO setting
CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_3);
//DCO为4M.问题1:这里为什么要设置DCO时钟
//Select XT1 as the clock source for ACLK with no frequency divider
CS_clockSignalInit(CS_ACLK,CS_LFXTCLK_SELECT,CS_CLOCK_DIVIDER_1);
//LFXTCLK做ACLK时钟源
//Start XT1 with no time out
CS_LFXTStart(CS_LFXTDRIVE_0);
//驱动LFXTCLK晶振,
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2,
GPIO_PIN2,
GPIO_SECONDARY_MODULE_FUNCTION
);
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P1,
GPIO_PIN6 + GPIO_PIN7,
GPIO_SECONDARY_MODULE_FUNCTION
);
PMM_unlockLPM5();
//Initialize Master
EUSCI_B_SPI_initMasterParam param = {0};
param.selectClockSource = EUSCI_B_SPI_CLOCKSOURCE_ACLK;
//用ACLK作SPI时钟
param.clockSourceFrequency = CS_getACLK();
//问题2,没弄明白这里做什么用API手册里就一句话Is the frequency of the selected clock source.
param.desiredSpiClock = 500000;
//这里是设置SPI时钟频率??API手册里说Is the desired clock rate for SPI communication.
param.msbFirst = EUSCI_B_SPI_MSB_FIRST;
//下面都理解spi的常规设置
param.clockPhase = EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT;
param.clockPolarity = EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH;
param.spiMode = EUSCI_B_SPI_3PIN;
EUSCI_B_SPI_initMaster(EUSCI_B0_BASE, ¶m);
以下是修改的程序
本帖最后由 曾经in 于 2015-2-11 15:19 编辑