Quantcast
Channel: Data converters
Viewing all articles
Browse latest Browse all 28840

Forum Post: RE: CCS/ADS8699: ADS8699 SPI DMA example c code

$
0
0
Hi, thank you for writing. CS is low I recognised. I wired it as you can see in the code. At first i want to test directly with SPI, later with SPI with DMA because its more complicated. From the example I changed the clock and EUSCI_B0_MODUL to EUSCI_B0_BASE because ...MODUL i isn't declared a msp432 i would say. It looks like this: /* MSP432 = SPI master, external device = SPI slave * * MSP432P401 ADS8699 * ----------------- ----------------- * | | | | * | 5V |-> ->| DVDD | * | | | | * | GND |-> ->| DGND | * | | | | | P4.3 |-> _CS ->| CST/CS | * | | | | * | P1.6 |-> Data Out (UCB0SIMO) ->| SDI | * | | | | * | P1.7 | Serial Clock Out (UCB0CLK) ->| SCLK | **********************************************************************************************/ #include #include #include #include static volatile uint8_t RXData[10]; static volatile uint8_t i = 0; static uint8_t TXData = 0; static uint8_t ii = 0; /* 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_LOW, // low polarity EUSCI_B_SPI_3PIN // 3Wire SPI Mode }; int main(void) { volatile uint32_t ii; /* Halting WDT */ WDT_A_holdTimer(); /* Starting and enabling LFXT (3MHz) */ GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION); CS_setExternalClockSourceFrequency(3000000, 0); CS_initClockSignal(CS_SMCLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1); CS_startLFXT(CS_LFXT_DRIVE0); /* Selecting P1.0 as LED */ GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0); GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0); /* SPI --> P4.3 = _CS, P1.5 = CLK, P1.6 = MOSI & P1.7 = MISO */ GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION); GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_PIN3); GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3); /* Configuring SPI in 3-wire master mode & enabling it & interrupts */ SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig); SPI_enableModule(EUSCI_B0_BASE); SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT); Interrupt_enableInterrupt(INT_EUSCIB0); //Interrupt_enableSleepOnIsrExit(); /* Delaying waiting for the module to initialize */ for(ii=0;ii<100;ii++); /* SPI, put _CS low P4.3 and polling to see if the TX buffer is ready or busy */ GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3); // TXData = 0x40; // while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); // SPI_transmitData(EUSCI_B0_BASE, TXData); // TXData = 0x00; // while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); // SPI_transmitData(EUSCI_B0_BASE, TXData); while(1) {} /*PCM_gotoLPM0(); __no_operation();*/ } void euscib0_isr(void) { int i = 0; uint32_t status = SPI_getEnabledInterruptStatus(EUSCI_B0_BASE); SPI_clearInterruptFlag(EUSCI_B0_BASE, status); if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT) { RXData[i++] = SPI_receiveData(EUSCI_B0_BASE); if ((i % 2) == 1) { for( ii=0;ii<10;ii++); GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3); } GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0); for(i=0;i<48000000;i++); // delay 1s GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0); } } The Software is always at while(1), the function euscib0_isr() isn't entered. I think that with _CS low the ADC starts working and send an interrupt. But how does this work "send an interrupt" to the msp432?

Viewing all articles
Browse latest Browse all 28840

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>