- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to get a 12 bit dac working with the PSOC. Painful, but here is how it worked:
I connected up to a 12 bit dac from the PSoC using the SPI Master unit.
The 12 bit dac requires the Load signal to go low and then high when the data should be loaded. You can only send 12 bits at a time to the DAC, 16 bits does not work.
I was able to accomplish this by connecting tx_interrupt through a NOT gate to a pin. I then set the "Interrupt on Byte/Word transfer Complete" checkbox.
I then set the bits to send to 12 bits.
With this, you do a write to the transmit registe to get things primed.
uint16 *sp=sineBuffer;
SPI_Master_WriteTxData(sp[index++]);
Then, in a forever loop, using a sine wave buffer for a test, (the buffer is placed in pointer sp):
for(;;)
{
/* Place your application code here. */
if (SPI_Master_ReadTxStatus() & SPI_Master_STS_SPI_DONE) {
SPI_Master_WriteTxData(sp[index++]);
if (index >7 ) {
index=0;
sp=sineBuffer;
}
}
}
Now the interesting part. DMA does not appear to work with a 12 bit SPI, unless I'm missing something. I suppose you could write two 8 bit bytes at incrementing addresses, but the DMA unit does not appear to want to do this unless it is always incrementing, and we only want to write to the transmit register.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you write to the SPI FIFO, you always write to the same register (its a FIFO after all). No need to increase addresses. You need to increment the source address, though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure if these can help, reference material -
http://www.cypress.com/?rID=37793 AN52705 Getting Started with DMA
http://www.cypress.com/?rID=82680 AN84810 PSoC® 3 and PSoC 5LP Advanced DMA Topics
http://www.cypress.com/?rID=44335 AN61102 PSoC® 3 and PSoC 5LP - ADC Data Buffering Using DMA
http://video.cypress.com/video-library/search/dma/ Videos on DMA
https://www.youtube.com/results?search_query=dma+psoc Videos on DMA (some overlap)
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After several days of work, I have come to the conclusion that the included SPI component will easily work with DMA in 8 bit mode. I have been successful in working with the SPI in 8 bit mode. That mode works well.
Unfortunately, the 12 bit DAC device only accepts 12 bits of data. Additonal data doesn't work, so you can not send two 8 bit bytes (with 12 bits of info) and get a good DAC output.
If you put the SPI in 12 bit mode, it cannot work with the DMA engine, as the DMA engine only does 8 bit writes, whereas the SPI has a 16 bit register when in 12 bit mode, and you do a single 16 bit write. I traced the API to verify this.
The DMA engine is very simple, and very robust, and 8 bits only. It is easy to work with, and I've not had any issues with it working if it is set up properly and the right signals are fed to it. The DMA engine is not the problem. Its design might be lacking, but it is a solid DMA unit, and gives far less trouble than, for example, Intel's DMA units.
It would be good if Cypress could upgrade their DMA engine to 16 bits, but if wishes were horses, everyone could ride.
However, don't worry. Of all the dozen or so DMA units I've worked with, the Cypress DMA unit is up there with the best of them. No one gets DMA 100% right.
On the flip side, none of my designs are ever right, either.
I am investigating creating my own component for this purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
DMA width is max 32bits wide. 8 or 16 bits are not too complicated to maintain.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK. I'll bite. How do I transfer to 12 bit SPI using DMA?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Some DMA ref material -
http://www.cypress.com/?rID=37793 AN52705 Getting Started with DMA
http://www.cypress.com/?rID=82680 AN84810 PSoC® 3 and PSoC 5LP Advanced DMA Topics
http://www.cypress.com/?rID=44335 AN61102 PSoC® 3 and PSoC 5LP - ADC Data Buffering Using DMA
http://video.cypress.com/video-library/search/dma/ Videos on DMA
https://www.youtube.com/results?search_query=dma+psoc Videos on DMA (some overlap)
As an aside you are using external 12 bit DAC, is that because of speed needs ? If
you want an internal one, low speed/settling time, you can get one up to 16 bits with a PWM
followed by LPF/Integrator.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, we need 12 bits and 20khz or higher speed.
Once you get past 8 bits with the SPI, DMA transfers start failing, even with 2 bytes per burst.
The DMA unit appears to only work with 8 bit SPI, based on my tests.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@ Bob Tested.
That code fails with 12 bit SPI (2 bytes per burst)
That code works with 8 bit SPI. Only change is number of bits for the SPI unit.
I'm working on some logic to enable/disable the SPI clock and trigger the load signal after 12 bits, in 8 bit mode.
Your design and my design were identical.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I filed a technical case about that. I'll keep you informed as soon as there are any results.
Bob