- Fri Jan 05, 2018 10:59 am
#197789
I am trying to configure a SparkFun Minigen using the existing MiniGen Arduino library. However, I am using a TI MSP432 as the controller and not an Arduino.
On the face of it, this should be relatively simple as it's just a matter of configuring the TI to send the control bits to the MiniGen using their own SPI libraries. However, I am having a bear of a time figuring out why this isn't working and am quite frankly totally stuck with how to move forward.
I have included the C code below - I am using the Minigen.c and Minigen.h libraries provided on the Github page (https://github.com/sparkfun/MiniGen/blo ... iniGen.cpp) with no modifications. The only changes I have made are to the TI code, which only transmits one byte at a time. Can anyone point out what is wrong with trying to even reset the MiniGen? All I am getting is a 1 Vpp sin wave at 3 MHz.
On the face of it, this should be relatively simple as it's just a matter of configuring the TI to send the control bits to the MiniGen using their own SPI libraries. However, I am having a bear of a time figuring out why this isn't working and am quite frankly totally stuck with how to move forward.
I have included the C code below - I am using the Minigen.c and Minigen.h libraries provided on the Github page (https://github.com/sparkfun/MiniGen/blo ... iniGen.cpp) with no modifications. The only changes I have made are to the TI code, which only transmits one byte at a time. Can anyone point out what is wrong with trying to even reset the MiniGen? All I am getting is a 1 Vpp sin wave at 3 MHz.
Code: Select all
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SPI.h>
#include "minigen.h"
/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
/* SPI Master Configuration Parameter */
const eUSCI_SPI_MasterConfig spiMasterConfig =
{
EUSCI_B_SPI_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
3000000, // SMCLK = DCO = 3MHZ
500000, // SPICLK = 500khz
EUSCI_B_SPI_MSB_FIRST, // MSB First
EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, // Phase
EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH, // High polarity
EUSCI_B_SPI_3PIN // 3Wire SPI Mode
};
void configSpi(){
/* Selecting P1.5 P1.6 and P1.7 in SPI mode */
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
/* P1.5 SCLK, P1.6 SIMO */
/* Configuring SPI in 3wire master mode */
SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig);
/* Enable SPI module */
SPI_enableModule(EUSCI_B0_BASE);
//Pin 3.0 FSYNC
GPIO_setOutputHighOnPin(GPIO_PORT_P3, GPIO_PIN0);
}
void SpiWrite(uint16_t data){
int n = 0;
GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_PIN0);
for (n = 0; n <= 1; n++)
SPI_transmitData(EUSCI_B0_BASE, (data >> (8*n)) & 0xff);
GPIO_setOutputHighOnPin(GPIO_PORT_P3, GPIO_PIN0);
}
int main(void)
{
/* Halting WDT */
WDT_A_holdTimer();
configSpi();
minigen_reset();
while (1) {
};
}