Other Parts Discussed in Thread: HALCOGEN
Hello,
I am looking for a example code with SPI in master mode using DMA functionality
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I am looking for a example code with SPI in master mode using DMA functionality
Hi Usha,
Please refer below link
6.1. Project 0 — Hercules Safety MCUs Documentation
--
Thanks & Regards,
Jagadish.
Hi Jagadish,
Thanks for the reply. I tried the example code from the repository. I need to adapt a bit. But I have an issue . After enabling spi dma transfer I see only the clock no data sent is over MOSI. Can you guide me on this ?
Hi Usha,
Can you please make sure below things
1. If MOSI pin has multiple pin functionalities, then make sure the MOSI is enabled in pin mux

If the pin doesn't have multiple functionalities, then there is no need to configure here in fact such pins are not listed in HALCoGen pinmux window.
2. Make sure MOSI pin direction is enabled to output

In above pin the SPI is selected as master, so MOSI signal is selected as output and MISO signal is selected as input by not enabling direction, make sure same thing in your project.
3. Finally make sure you are probing right pin to measure MOSI.
--
Thanks & Regards,
Jagadish.
cross checked everything you mentioned. I still have the same behavior
Thanks and warm regards
Usha
Hi Usha,
Is it possible to you to attach your code? So that i can easily verify what is wrong?
--
Thanks & Regards,
Jagadish.
No usha, i can't able to access it.
Can you please zip the whole project and attach it? because from only main.c i can't verify the HALCoGen configuration.
After zip the project please click on Insert button

Now click on image/video/file option

Now click on Upload option

Now browse to the path of zip and select it and upload it.
--
Thanks & Regards,
Jagadish.
Thanks Usha, now i can be able to download it.
I will verify and give you an update.
Hi Usha,
Please check once by disabling the cache

Uncheck above box and regenerate the code and test it.
--
Thanks & Regards,
Jagadish.
Hi Usha,
I forgot mention one more modification i did,
We have to reverse the frame count and element count inputs given to DMA (i.e. Element count should be 1 and frame count should be 128 ), it is because whenever data moved to DAT1 register to the shift register the DMA will get trigger at that time we should move only one element only not 128 at the same time.
After doing above changes you can see SPI3 MOSI output as below, i tested at my end

I am attaching my project here, just take it as reference and test it
Note1: In my project properties the debug probe is XDS100v2 because i am testing on HDK board not XDS110 as yours.
Note2: If you want to stop the DMA communication after 128 elements, please make it AUTOINIT_OFF otherwise data will continuously send even after 128 bytes also

--
Thanks & Regards,
Jagadish.
Thanks Jagadish I could get it working as well from Master side. But have issue with slave receive
warm regards
Usha
Hi Usha,
Can you elaborate the issue you are facing on slave side?
--
Thanks,
Jagadish.
Hi Jagadish,
Thanks for getting back.well I don't get DMA BTC interrupt triggered and receive buffer of SPI1 (slave) is empty. This is what i have configured on halcogen
SLAVE: uncheck master mode, internal clock then uncheck output direction of CS_0 .
DMA is always busy ( GlbCtrl 0x00010300 )
Hi Usha,
Sorry for the delay,
If slave side data is not at all receiving, then make sure the b below things,
1. ENA pin should be on GIO side for slave SPI.

2. Internal clock should be in disable on slave side

Make sure these two things and let me know the status.
--
Thanks & Regards,
Jagadish.
Hi Jagadish,
Thanks for the reply. Didn't help same behavior still.
warm regards
Usha
Hi Usha,
Can you please open HALCoGen configuration in below project and make sure that we configured in the same way
--
Thanks & Regards,
Jagadish.
Hi Jagadish
are you sure this is the right file you have sent . since I see ENA as been configured as SPI functional pin on slave side .
Hi Usha,
Yes, it is right project.
Don't configure ENA and except that make sure remaining things are as per the shared project and test it once. Let me know the result, i.e, are you seeing any data in received buffer or not?