2021-01-27 03:04 AM
Hey Community,
i am working on a parallel output interface. I want to realize it with GPIOE and all of the 16 Pins.
To Generate an output i used TIM2 to trigger DMA1 so far so good. The Output is working with memory to peripheral. The DMA is copying the databytes from the SRAM into the GPIOE->ODR Register (fmax=24MHz). Now i want to use HRTIM to generate the DMA request for more precise and faster Output.
I could not get it to run. Here my Code:
ALIGN_32BYTES(__attribute__((section (".sram1_s0"))) uint32_t msg2[]) =
{
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000),
((uint16_t)0x0100),((uint16_t)0x0000)
};
void New_HRTIM(void){
__HAL_RCC_DMA1_CLK_ENABLE();
__HAL_RCC_DMA2_CLK_ENABLE();
__HAL_RCC_HRTIM1_CONFIG(RCC_HRTIM1CLK_CPUCLK);
__HRTIM1_CLK_ENABLE();
hhrtim1.Instance = HRTIM1;
hhrtim1.Init.HRTIMInterruptResquests = HRTIM_IT_NONE;
hhrtim1.Init.SyncOptions = HRTIM_SYNCOPTION_NONE;
HAL_HRTIM_Init(&hhrtim1);
HRTIM_TimerCfgTypeDef pTimerCfg = {0};
pTimerCfg.InterruptRequests = (HRTIM_MASTER_IT_NONE | HRTIM_TIM_IT_NONE);
pTimerCfg.DMARequests = HRTIM_TIM_DMA_RST;
pTimerCfg.DMASrcAddress = (uint32_t)&msg2;
pTimerCfg.DMADstAddress = (uint32_t)&(GPIOE->ODR);
pTimerCfg.DMASize = sizeof(msg2);
pTimerCfg.HalfModeEnable = HRTIM_HALFMODE_DISABLED;
pTimerCfg.StartOnSync = HRTIM_SYNCSTART_DISABLED;
pTimerCfg.ResetOnSync = HRTIM_SYNCRESET_DISABLED;
pTimerCfg.DACSynchro = HRTIM_DACSYNC_NONE;
pTimerCfg.PreloadEnable = HRTIM_PRELOAD_DISABLED;
pTimerCfg.UpdateGating = HRTIM_UPDATEGATING_INDEPENDENT;
pTimerCfg.BurstMode = HRTIM_TIMERBURSTMODE_MAINTAINCLOCK;
pTimerCfg.RepetitionUpdate = HRTIM_UPDATEONREPETITION_DISABLED;
pTimerCfg.PushPull = HRTIM_TIMPUSHPULLMODE_DISABLED;
pTimerCfg.FaultEnable = HRTIM_TIMFAULTENABLE_NONE;
pTimerCfg.FaultLock = HRTIM_TIMFAULTLOCK_READWRITE;
pTimerCfg.DeadTimeInsertion = HRTIM_TIMDEADTIMEINSERTION_DISABLED;
pTimerCfg.DelayedProtectionMode = HRTIM_TIMER_A_B_C_DELAYEDPROTECTION_DISABLED;
pTimerCfg.UpdateTrigger = HRTIM_TIMUPDATETRIGGER_NONE;
pTimerCfg.ResetTrigger = HRTIM_TIMRESETTRIGGER_NONE;
pTimerCfg.ResetUpdate = HRTIM_TIMUPDATEONRESET_DISABLED;
if (HAL_HRTIM_WaveformTimerConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, &pTimerCfg) != HAL_OK)
{
Error_Handler();
}
__HAL_HRTIM_ENABLE(&hhrtim1, HRTIM_TIMERUPDATE_A);
HAL_HRTIM_WaveformOutputStart(&hhrtim1, (HRTIM_OUTPUT_TA1 | HRTIM_OUTPUT_TA2));
HAL_HRTIM_WaveformCounterStart_DMA(&hhrtim1,HRTIM_TIMERID_TIMER_A);
HAL_HRTIM_UpdateEnable(&hhrtim1, HRTIM_TIMERUPDATE_A);
ConsolePrintUsart3("while start..");
int i = 0;
while(1) {
i += 1;
}
}