Other Parts Discussed in Thread: SYSCONFIG, MSPM0G3507
Hello everyone,
I'm trying to use a timer to trigger ADC sampling on LP-MSPM0G3507 (Rev. A) using a zero event.
I'm using sysconfig of CCS Theia 1.2.0 to configure module TIMA0: specifically I'm making it to work in periodic down-counting mode, with a period of 50us, and zero events as trigger for ADC, as you can see in the following image:
Running my code I found out that the sampling was happening much faster that expected (TIMA0_CTR changing values too fast considering code), causing some erratic behaviour.
I tried to look for a way to easily measure my code timing, but considering that MSPM0G3507 doesn't seem to have available the possibility to use Clock Counts breakpoints or Profile Clock, i tried using SysTick to have a mean to compare its downcounting to the one of TIMA0: to my surprise SysTick is behaving exactly as expected, having a downcount consistent with my code.
I'm really baffled about this problem, so I'm wondering if it could involve some clocking setting I'm not aware of or something else I'm missing about this system.
The following image is how I configured SYSCTL and SYSTICK and you can find my code.
#include "ti/devices/msp/peripherals/hw_flashctl.h" #include "ti/driverlib/dl_dma.h" #include "ti/driverlib/dl_adc12.h" #include "ti/driverlib/dl_timera.h" #include "ti_msp_dl_config.h" #include <sys/_stdint.h> uint16_t Sample_Buffer[12] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }; uint16_t test = 0x0000; uint16_t DMA_transfer_control = 0x0000; int main(void) { SYSCFG_DL_init(); DL_DMA_setSrcAddr (DMA, DMA_CH0_CHAN_ID, DL_ADC12_getMemResultAddress(ADC12_0_INST, DL_ADC12_MEM_IDX_0 )); DL_DMA_setDestAddr (DMA, DMA_CH0_CHAN_ID, (uint32_t) &Sample_Buffer[0]); DL_DMA_enableChannel(DMA, DMA_CH0_CHAN_ID); NVIC_EnableIRQ(ADC12_0_INST_INT_IRQN); DL_SYSTICK_enable(); DL_Timer_startCounter(TIMER_0_INST); while (DMA_transfer_control < 0x0003) { __WFI(); } test = 0x1111; while (1) { } } void ADC12_0_INST_IRQHandler(void) { switch (DL_ADC12_getPendingInterrupt(ADC12_0_INST)) { case DL_ADC12_IIDX_DMA_DONE: DMA_transfer_control++; DL_DMA_setSrcAddr (DMA, DMA_CH0_CHAN_ID, DL_ADC12_getMemResultAddress(ADC12_0_INST, DL_ADC12_MEM_IDX_0 )); DL_DMA_setTransferSize(DMA, DMA_CH0_CHAN_ID, 3); DL_DMA_enableChannel(DMA, DMA_CH0_CHAN_ID); DL_ADC12_enableConversions(ADC12_0_INST); break; default: break; } }
Thanks in advance for your help.
Best Regards,
Stefano