DAC Sinus Demo (using PEx + KSDK 1.2 + KDS 3.0)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

DAC Sinus Demo (using PEx + KSDK 1.2 + KDS 3.0)

DAC Sinus Demo (using PEx + KSDK 1.2 + KDS 3.0)

Created DAC Sinus example is PIT triggered with own buffer and is for FRDM-K64F.

 

  • adding analog component fsl_dac peripheral driver to project

33950_33950.png1.png

  • setting Voltage reference - Reference 2 for dac component (daConv1:fsl_dac)

33949_33949.png2.png

  • adding timer component fsl_pit peripheral driver to project

33951_33951.png3.png

  • setting period on 1 ms and enabling interrupts for timer component (pitTimer1:fsl_pit)

33952_33952.png4.png

33953_33953.png5.png

  • setting buffer for sinusoidal in Sources -> Events.c
#define DAC_TEST_BUFF_SIZE  (120U) uint16_t dac_buffer[DAC_TEST_BUFF_SIZE] =     {         
0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,         
0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,         
0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,         
0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,        
 0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,         
0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,         
0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,         
0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,         
0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,         
0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,         
0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,         
0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794       }; 

uint16_t index = 0; 
void pitTimer1_IRQHandler(void) {   

/* Clear interrupt flag.*/   
PIT_HAL_ClearIntFlag(g_pitBase[FSL_PITTIMER1], FSL_PITTIMER1_CHANNEL);   

/* Write your code here ... */    

DAC_DRV_Output(FSL_DACONV1,dac_buffer[index++]);   
if(index==DAC_TEST_BUFF_SIZE)       index = 0;  }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

  • FRDM-K64F with SALEAE

33955_33955.jpgunnamed.jpg

33956_33956.jpgdetail.jpg

 

  • sinusoidal output

 

32563_32563.pngvystup_.png

 

Enjoy!

ラベル(1)
添付
コメント

Hi Iva,

The example was very very usefull :smileyhappy:.

Just a question:

How do you make your buffer to generate a signal? I use EXCEL to do so, but, is there any other way to do it?

Thanks,

Jordan c:

Hello Jordan,

thank you for the question, I forget mentioned it.

For getting these values you can count it :-) or put them to Sine Generator with values for max amplitude.

E.g. you can use any on-line sine generator, like Sine Look Up Table Generator Calculator and fill the values with

values.png

where Number of points are array values, for dac_buffer[DAC_TEST_BUFF_SIZE],

Max amplitude is (2^12) -1 and Number Per Row is value for showing results.

After that you get these values: (I see there is a small difference between values, but it can be caused by rounding)

values_4095.png

I hope it helps you,

Best Regards,

Iva

Thank you! 

This was useful... however I need to get a 13kHz or so sinusoid out of the DAC, so I would like a much higher sample rate. I don't want to suck up too many resources trying to make this signal, so I would like to use the DMA to offload the interrupt load. The example in the PE beans is for an obsolete DMA method, and I cannot get the DMA example to work quite right, as I am getting DAC output, but it is not referencing my table properly (I get 1 of every 16 samples correct, the rest are a sawtooth which is odd). The timing is right, the DMA interrupts are firing, but the DMA is a bit confusing so I need help. Clearly I do not have the DMA set up correctly.

It would be great if you could expand on this example to use DMA on the MKV31F

Thanks!

評価なし
バージョン履歴
最終更新日:
‎09-10-2020 01:39 AM
更新者: