欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
stm32 DMA實(shí)驗(yàn)程序
[打印本頁(yè)]
作者:
柯南240
時(shí)間:
2019-3-9 08:05
標(biāo)題:
stm32 DMA實(shí)驗(yàn)程序
stm32DMA數(shù)據(jù)傳輸實(shí)驗(yàn)
單片機(jī)源程序如下:
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#include "LCD.h"
/* Private functions ---------------------------------------------------------*/
u8 buffer[100];
void GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE, ENABLE);
//USART的TX和RX管腳
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA , &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//LED燈
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void USART_Config(void)
{
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
//配置USART狀態(tài)
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl =
USART_HardwareFlowControl_None;
USART_Init(USART1 , &USART_InitStructure);
USART_Cmd(USART1 , ENABLE);
}
void DMA_Config(void)
{
DMA_InitTypeDef DMA_InitStruct;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
DMA_InitStruct.DMA_PeripheralBaseAddr=0x40013804;
DMA_InitStruct.DMA_MemoryBaseAddr =(u32)buffer;
DMA_InitStruct.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStruct.DMA_BufferSize = 100;
DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStruct.DMA_Mode = DMA_Mode_Normal;
DMA_InitStruct.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStruct.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel4, &DMA_InitStruct);
}
void putData(u8 ch)
{
USART_SendData(USART1,ch);
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);
}
void Delay(unsigned k)
{
unsigned j;
for(j=0;j<=k;j++);
}
void Led1(void)
{
GPIO_ResetBits(GPIOC, GPIO_Pin_6);
Delay(0xfffff);
GPIO_SetBits(GPIOC, GPIO_Pin_6);
}
void Led4(void)
{
GPIO_SetBits(GPIOC, GPIO_Pin_9);
Delay(0xfffff);
GPIO_ResetBits(GPIOC, GPIO_Pin_9);
}
int main(void)
{
unsigned i,j=0;
unsigned char TxBuf1[100] = " welcome to yubing's home!";
#ifdef DEBUG
debug();
#endif
SystemInit();
lcd_init ();
GPIO_Config();
USART_Config();
DMA_Config();
lcd_clear ();
lcd_putCustomChar();
lcd_print("is a pig");
for(i=0;i<=100;i++)
{
buffer[j]=TxBuf1[i];
j++;
}
USART_DMACmd(USART1,USART_DMAReq_Tx,ENABLE);
DMA_Cmd(DMA1_Channel4, ENABLE);
while(DMA_GetFlagStatus(DMA1_FLAG_TC4)==RESET)
{
Led4();
}
while(1)
{
}
}
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
復(fù)制代碼
所有資料51hei提供下載:
project8_DMA.7z
(174.72 KB, 下載次數(shù): 8)
2019-3-10 21:17 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
admin
時(shí)間:
2019-3-10 21:18
本帖需要重新編輯補(bǔ)全電路原理圖,源碼,詳細(xì)說(shuō)明與圖片即可獲得100+黑幣(帖子下方有編輯按鈕)
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1