Skip to content

Instantly share code, notes, and snippets.

@2garryn
Created March 15, 2017 14:52
Show Gist options
  • Save 2garryn/23618e29817611c02734c932a5d0a829 to your computer and use it in GitHub Desktop.
Save 2garryn/23618e29817611c02734c932a5d0a829 to your computer and use it in GitHub Desktop.
DMA_DeInit(DMA1_Stream5);
DMA_INIT.DMA_Channel = DMA_Channel_7;
DMA_INIT.DMA_PeripheralBaseAddr = (uint32_t)&DAC->DHR12L1;//->DHR12R1;// &DAC->DHR12L1; DHR8R1;
DMA_INIT.DMA_Memory0BaseAddr = (uint32_t)&dac_buff;
DMA_INIT.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_INIT.DMA_BufferSize = 512;
DMA_INIT.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_INIT.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_INIT.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_INIT.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_INIT.DMA_Mode = DMA_Mode_Circular;
DMA_INIT.DMA_Priority = DMA_Priority_High;
DMA_INIT.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_INIT.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_INIT.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_INIT.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA1_Stream5, &DMA_INIT);
@shljonki
Copy link

Hey,

Im trying to address Memory0BaseAddr to DMA based on character i get from USART. so my code looks like this:
small part of DMA.c looks like:
void put(){
znak=USART_ReceiveData(USART1);
if (a!=znak){
USART1_SendChar(znak);
a=znak;

		DMA_InitTypeDef DMA_INIT;
		if (a == '6'){
		  baf_size = SINE;
		  DMA_INIT.DMA_Memory0BaseAddr    = (uint32_t)&sine;}
                if (a == '2'){
		   baf_size = WAVE_RES_35;
		   DMA_INIT.DMA_Memory0BaseAddr    = (uint32_t)&signal_102;}
                    if (a == '3'){ 
		   baf_size = WAVE_RES_50;
		   DMA_INIT.DMA_Memory0BaseAddr    = (uint32_t)&signal_103;}
	
	DMA_INIT.DMA_BufferSize         = baf_size;
	DMA_Init(DMA1_Stream5, &DMA_INIT);
		USART1_SendChar(znak);}
	}

my main.c looks like:
int main(void){

gpio_init();
DAC1_init();
TIM6_init();
USART1_Init();

while(1){ stavi();
	//funk(&znak);
}

}

i just get random signal like none of if{}s passed the check, even though i really type 2,3, or 6.
I tested serial communication and it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment