AnsweredAssumed Answered

Conflict of JTAG Programmer and continuous read from ADC to DMA on STM32F103RB

Question asked by kwiatkowski.damian on Sep 28, 2011
Latest reply on Oct 3, 2011 by Clive One
Hello,
I have a troubles with JTAG programmers if on my processor runs following program:

    RCC_ADCCLKConfig(RCC_PCLK2_Div8);

    DMA_DeInit(DMA1_Channel1);
    DMA_InitTypeDef dmaInitStructure;
    DMA_StructInit(&dmaInitStructure);
    dmaInitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR;
    dmaInitStructure.DMA_MemoryBaseAddr = (uint32_t)m_sensorsValues;
    dmaInitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
    dmaInitStructure.DMA_BufferSize = sizeof(m_sensorsValues)/sizeof(m_sensorsValues[0]);
    dmaInitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
    dmaInitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
    dmaInitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
    dmaInitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
    dmaInitStructure.DMA_Mode = DMA_Mode_Circular;
    dmaInitStructure.DMA_Priority = DMA_Priority_Low;
    dmaInitStructure.DMA_M2M = DMA_M2M_Disable;
    DMA_Init(DMA1_Channel1, &dmaInitStructure);
    DMA_Cmd(DMA1_Channel1, ENABLE);

    ADC_InitTypeDef adcInitStructure;
    ADC_StructInit(&adcInitStructure);
    adcInitStructure.ADC_Mode = ADC_Mode_Independent;
    adcInitStructure.ADC_ScanConvMode = ENABLE;
    adcInitStructure.ADC_ContinuousConvMode = ENABLE;
    adcInitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
    adcInitStructure.ADC_DataAlign = ADC_DataAlign_Right;
    adcInitStructure.ADC_NbrOfChannel = 3;
    ADC_Init(ADC1, &adcInitStructure);

    //CO
    ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 1, ADC_SampleTime_239Cycles5);
    //CWU
    ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 2, ADC_SampleTime_239Cycles5);
    //MOSFET
    ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 3, ADC_SampleTime_239Cycles5);
    //SPALIN
    //ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 4, ADC_SampleTime_239Cycles5);

    ADC_DMACmd(ADC1, ENABLE);
    ADC_Cmd(ADC1, ENABLE);

    ADC_ResetCalibration(ADC1);
    while (ADC_GetResetCalibrationStatus(ADC1));

    ADC_StartCalibration(ADC1);
    while (ADC_GetCalibrationStatus(ADC1));

    ADC_SoftwareStartConvCmd(ADC1, ENABLE);


The program works fine, but I can't download new program because the programmer corrupts. If I use ST-Link programmer and ST-LinkUtility then I can erease processor but if I have any alternative software I can't do it. I try this on OLIMEX programmer and ereasing program after write above program is imposible. If I disable DMA or if I disable continous read from ADC, it works fine. What I can do? This is done as well as in official example.

Outcomes