Hello Gregor, 

I'm actually working on a project incolving a SPI connection between a 
BeagleBone black and an AD7606 (ADC). I have a couple of problems to enable 
properly the SPI connection, could you give me more details about how you 
have done it ? (if it worked).

I'm programming the BB_black in bare-metal, and it will communicate with 
the ADC using the SPI, so I really need to find out how to do it in order 
for my system to work.

Best regards,

Cedric.


Le dimanche 31 août 2014 14:03:31 UTC+2, Gregor Steiner a écrit :
>
> Hi,
>
> I want to use SPI through direct memory access on Debian, here is what I 
> got so far:
>
> int enableSPIClock()
> {
>     // map a pointer to the clock control block
>     pClockControl = (char*)mmap(0, 4096, PROT_READ | PROT_WRITE, 
> MAP_SHARED, memFd, SOC_CM_PER_REGS);
>
>     HWREG(pClockControl + CM_PER_SPI1_CLKCTRL) |= 
> CM_PER_SPI1_CLKCTRL_MODULEMODE_ENABLE;
>     while(CM_PER_SPI1_CLKCTRL_MODULEMODE_ENABLE != (HWREG(pClockControl + 
> CM_PER_SPI1_CLKCTRL) & CM_PER_SPI1_CLKCTRL_MODULEMODE));
>     
>     return 0;
> }
>
> int enableSPI()
> {
>     enableSPIClock();
>     
>     McSPIReset(spi);
>     McSPICSEnable(spi);
>     McSPIMasterModeEnable(spi);
>     
>     // set D0 as output-MOSI , set D1 as input-MISO
>     McSPIMasterModeConfig(spi, MCSPI_MULTI_CH, MCSPI_TX_RX_MODE, 
> MCSPI_CH0CONF_DPE0_ENABLED | MCSPI_CH0CONF_DPE1_DISABLED, chNum);
>     McSPIClkConfig(spi, 48000000, 6000000, chNum, MCSPI_CLK_MODE_0);
>     McSPIWordLengthSet(spi, MCSPI_WORD_LENGTH(8), chNum);
>     McSPICSPolarityConfig(spi, MCSPI_CS_POL_LOW, chNum); 
>     McSPITxFIFOConfig(spi, MCSPI_TX_FIFO_ENABLE, chNum); 
>     McSPIRxFIFOConfig(spi, MCSPI_RX_FIFO_ENABLE, chNum);
>     
>     return 0;
> }
>
> int spiWrite(uint8_t *tx, uint32_t length)
> {
>     // cs line is forced to low state.
>     McSPICSAssert(spi, chNum);
>
>     // enable the spi channel for communication.
>     McSPIChannelEnable(spi, chNum);
>
>     while (length > 0)
>     {
>         McSPITransmitData(spi, (unsigned int)(*tx++), chNum);
>         length--;
>         
>         unsigned int rx = McSPIReceiveData(spi, chNum);
>     }
>
>     // force cs line to the inactive state.
>     McSPICSDeAssert(spi, chNum);
>
>     // Disable the spi channel.
>     McSPIChannelDisable(spi, chNum);    
> }
>
> I'm writing to a DAC and every 2nd or 3rd message actually goes through 
> (gets recognized by the DAC).
>
> The StarterWare site 
> http://processors.wiki.ti.com/index.php/StarterWare_McSPI references the 
> *Interrupt 
> *and *DMA *mode, but I'm not sure if I should use them..?
> If anyone has tried a similar thing I'd be more than happy to hear about 
> it.
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/b76f52ec-e5a5-49d9-b4cb-24cc56e3c03e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to