2017-10-16 6 views
0

Bonjour, je commence à programmer un STM32F769I_Eval. Je suis un débutant absolument dans la programmation d'un Cortex M4 et l'utilisation d'un RTOS. J'ai utilisé les exemples de base pour commencer.RTX Keil et ADC_DMA, ne pas entrer GUI_thread

Maintenant, je veux utiliser l'ADC avec DMA pour afficher la valeur actuelle sur l'écran LCD. J'ai essayé cela auparavant dans un exemple simple sans RTOS et ça marche très bien.

Mais maintenant je construis un nouveau projet, mais l'affichage reste sombre. Il semble qu'après avoir utilisé HAL_ADC_START_DMA (...) il se bloque. Si je commente cette ligne, l'interface graphique est affichée à l'écran.

#include "main.h" 
#include "Board_LED.h"     // ::Board Support:LED 
#include "stm32f769i_eval_sdram.h"  // Keil.STM32F769I-EVAL::Board 
#include "stm32f7xx_hal.h"    // Keil::Device:STM32Cube HAL:Common 
#include "GUI.h"      // Segger.MDK-Pro::Graphics:CORE 
#include "cmsis_os.h" 
#include "RTE_Components.h"    // Component selection 


#ifdef _RTE_ 
#include "RTE_Components.h"    // Component selection 
#endif 
#ifdef RTE_CMSIS_RTOS     
#include "cmsis_os.h"     // CMSIS RTOS header file 
#endif 

#ifdef RTE_CMSIS_RTOS_RTX 
extern uint32_t os_time; 

uint32_t HAL_GetTick(void) { 
    return os_time; 
} 
#endif 
/* ADC handler declaration */ 
ADC_HandleTypeDef AdcHandle; 
__IO uint16_t uhADCxConvertedValue = 0; 
int32_t JTemp = 0x0; 

static void SystemClock_Config(void); 
static void Error_Handler(void); 
static void MPU_Config(void); 
static void CPU_CACHE_Enable(void); 
extern int Init_GUIThread (void); 
static void ADC_Config(void); 

int main(void) 
{ 

    MPU_Config(); 

    CPU_CACHE_Enable(); 

#ifdef RTE_CMSIS_RTOS     // when using CMSIS RTOS 
    osKernelInitialize();     // initialize CMSIS-RTOS 
#endif 

    HAL_Init(); 

    LED_Initialize(); 
    BSP_SDRAM_Init(); 

    SystemClock_Config(); 

    ADC_Config(); 

HAL_ADC_Start_DMA(&AdcHandle, (uint32_t*)&uhADCxConvertedValue, 1); 



#ifdef RTE_CMSIS_RTOS     

     osKernelStart();      // start thread execution 
     Init_GUIThread(); 
     GUI_Init(); 
#endif 

    /* Infinite loop */ 
    while (1) 
    { 

     HAL_Delay(1000); 
     osDelay(25); 

    } 
} 


static void ADC_Config(void) 
{ 

    ADC_ChannelConfTypeDef sConfig; 

    /* Configure the ADC peripheral */ 
    AdcHandle.Instance   = ADCx; 

    AdcHandle.Init.ClockPrescaler  = ADC_CLOCKPRESCALER_PCLK_DIV4; 
    AdcHandle.Init.Resolution   = ADC_RESOLUTION_12B; 
    AdcHandle.Init.ScanConvMode   = DISABLE;      
    AdcHandle.Init.ContinuousConvMode = ENABLE;       
    AdcHandle.Init.DiscontinuousConvMode = DISABLE;      
    AdcHandle.Init.NbrOfDiscConversion = 0; 
    AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;   
    AdcHandle.Init.ExternalTrigConv  = ADC_EXTERNALTRIGCONV_T1_CC1; 
    AdcHandle.Init.DataAlign    = ADC_DATAALIGN_RIGHT; 
    AdcHandle.Init.NbrOfConversion  = 1; 
    AdcHandle.Init.DMAContinuousRequests = ENABLE; 
    AdcHandle.Init.EOCSelection   = DISABLE; 

    if (HAL_ADC_Init(&AdcHandle) != HAL_OK) 
    { 
    /* ADC initialization Error */ 
    Error_Handler(); 
    } 

    sConfig.Channel = ADC_CHANNEL_8; 
    sConfig.Rank = 1; 
    sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; 
    sConfig.Offset = 0; 

    if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK) 
    { 
    /* Channel Configuration Error */ 
    Error_Handler(); 
    } 
} 

static void Error_Handler(void) 
{ 
    LED_On(1); 
    /* User may add here some code to deal with this error */ 
    while(1) 
    { 
    } 
} 

Je serais heureux si quelqu'un pouvait m'aider. Je suis également très reconnaissant pour certains guides, livres ou quelque chose comme ça.

Répondre

0

Apparemment, l'horloge ADC n'est pas activée. Implémentez-vous la fonction HAL_ADC_MspInit (généralement implémentée dans le fichier stm32f7xx_hal_msp.c)?

ou la deuxième variante, appelez-vous la fonction 'HAL_IncTick'?