Author Topic: PIC32MX795F512L Generate waveform using DMA and SPI DAC  (Read 1036 times)

0 Members and 1 Guest are viewing this topic.

Offline nick39Topic starter

  • Contributor
  • Posts: 13
  • Country: ar
PIC32MX795F512L Generate waveform using DMA and SPI DAC
« on: December 06, 2020, 01:33:18 pm »
Hi guys!

I'm new in the forum and also to PIC32. I need to generate a waveform using DMA.
Are there any examples I could use?
I haven't been able to find any. I'm not sure if I could do this using Harmony or if I have to code everything from scratch.
It doesn't seem to be much documentation about Harmony and registring to the Microchip Forum is impossible...

Thanks!
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3464
  • Country: it
Re: PIC32MX795F512L Generate waveform using DMA and SPI DAC
« Reply #1 on: December 07, 2020, 06:25:05 am »
the problem with SPI is that you have to generate the CS signal as well (and maybe also the LDAC pulse if you want the output to update at a specific, fixed rate)
I did it in the past (not with this MX but i don't recall anything that couldn't make it work), not sure if it's there is a better approach, but...

I used two CCP modules, SPI and DMA.
- CCP module 1 generate a small pulse for LDAC
- CCP module 2 generate a wider pulse, long enough that the SPI frame is contained in it
- DMA to start an SPI transfer with CCP module 2 as a trigger

I had also to be "clever", assigning different values to the CCP module timers so that they started out of phase between each other (so pulse 1 active would be while pulse 2 inactive) or if both CCP are run by the same timer, use output compare mode instead of PWM to achieve the same thing

Since you are new to PIC32, have you tried doing it the easy way first? (manual update, so you can confirm that connections are good)
« Last Edit: December 07, 2020, 06:45:11 am by JPortici »
 

Offline nick39Topic starter

  • Contributor
  • Posts: 13
  • Country: ar
Re: PIC32MX795F512L Generate waveform using DMA and SPI DAC
« Reply #2 on: December 09, 2020, 02:28:26 pm »
Thanks for your reply JPortici, I thought that the CS signal was always generated by hardware every time you write to SPI.
I found this website https://people.ece.cornell.edu/land/courses/ece4760/PIC32/index_SPI.html that says if you use Framed SPI it will generate the CS signal. Using this method there is no need to implement an ISR, am I right?
 

Offline fchk

  • Regular Contributor
  • *
  • Posts: 245
  • Country: de
Re: PIC32MX795F512L Generate waveform using DMA and SPI DAC
« Reply #3 on: December 10, 2020, 07:49:11 am »
Framed SPI is another word for TDM, of which I2S is a special type.

Standard SPI uses CS to mark enable transferring a certain number of bytes.

I2S doesn't have CS since it transmits continuously. It uses a frame or word clock to mark the start of a frame that contains a number of bytes representing a single or a pair of audio samples.

So, don't look for SPI DACs. Look for I2S DACs.

fchk
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf