STM32F407 -------------------------
uint16_t hT8Buff[4] = {1000,2000,3000,4000};
RCC_APB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE);
DMA_InitStructure.DMA_Channel = DMA_Channel_7;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&TIM8->CCR4;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)(hT8Buff);
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_BufferSize = 4;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream7, &DMA_InitStructure);
DMA_Cmd(DMA2_Stream7, ENABLE);
滤去TIM8的一些简单配置
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_Pulse = PWMPRD>>1;
TIM_OC4Init(TIM8, &TIM_OCInitStructure); //开启TIM8-CH4的输出
TIM_DMAConfig(TIM8,TIM_DMABase_CCR4,TIM_DMABurstLength_4Transfers);
TIM_DMACmd(TIM8,TIM_DMA_CC4,ENABLE);
TIM_Cmd(TIM8,ENABLE);
/**************************************************/
以上思想是,在TIM8->CCR4与TIM8->CNT 发送匹配的时候,触发DMA,传送hT8Buff里的数据更新TIM8->CCR4。。。。。。。。。
...现在的问题就是,TIM8->CCR4的值没变过。。。。。找了很久的原因,没找着....感觉不能过好年了,大家来帮忙吧!!!
一周热门 更多>