This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
void initClocks(void) {
// Disable watchdog timer
WDTCTL = WDTPW | WDTHOLD;
//Set DCO frequency to 8MHz
CS_setDCOFreq(CS_DCORSEL_0, CS_DCOFSEL_0);
//Set ACLK to use DCO at 8MHz
CS_initClockSignal(CS_ACLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
//Set SMCLK to use DCO at 8MHz
CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
}
void initSPI(void)
{
// Configure pins for SPI communication
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION); // MISO
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P1, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION); // MOSI
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN2, GPIO_PRIMARY_MODULE_FUNCTION); // CLK
GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN7); // Set MISO low by default
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN2); // CS
GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN2);
// Initialize eUSCI module for SPI
EUSCI_B_SPI_initMasterParam spiParams = {0};
spiParams.selectClockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK;
spiParams.clockSourceFrequency = 8000000; // Set SMCLK frequency to 8MHz
spiParams.desiredSpiClock = 8000000; // Set desired SPI clock to 8MHz
spiParams.msbFirst = EUSCI_B_SPI_MSB_FIRST;
spiParams.clockPhase = EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT;
spiParams.clockPolarity = EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW;
spiParams.spiMode = EUSCI_B_SPI_3PIN;
EUSCI_B_SPI_initMaster(EUSCI_B0_BASE, &spiParams);
EUSCI_B_SPI_enable(EUSCI_B0_BASE);
}
Hi! I'm working on creating a data logger using my MSP430 fraunchpad. Unfortunely, I am unable to get any sort of clock output on my SPI CLK on P2.2
Any assistance as to where I may have gone wrong with my clock setup would be greatly appreciated.
> GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION); // MISO
> GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P1, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION); // MOSI
> GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN2, GPIO_PRIMARY_MODULE_FUNCTION); // CLK
Scanning data sheet (SLAS639L) Tables 6-41/6-42, the PSEL settings for UCB0 are 10b, so you want GPIO_SECONDARY_MODULE_FUNCTION for each of them.
**Attention** This is a public forum