This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2L 无32K晶振初始化ADC失败

Other Parts Discussed in Thread: CC2640R2F

您好!

将工程从2640R2F移植到2640R2L,CCS版本V9.0.1.00004,没有换到最新的CCS,工程的设备还是选的CC2640R2F,目前移植后蓝牙连接,PWM,UART,GPIO中断等都没问题,就是ADC移植后无法使用,后面使用例程的顺序初始话,ADC_open这一步失败,贴出代码如下:

if(user_ADC_Handle[ADC_Channel] == NULL)   //static ADC_Handle user_ADC_Handle[USER_ADCCOUNT];
	{
	    ADC_init();
	   ADC_Params_init(&user_ADC_Params[ADC_Channel]);  //static ADC_Params user_ADC_Params[USER_ADCCOUNT];
	   user_ADC_Params[ADC_Channel].isProtected= true;
	   user_ADC_Handle[ADC_Channel]=ADC_open(0,&user_ADC_Params[ADC_Channel]);
	   if(user_ADC_Handle[ADC_Channel] == NULL)
	   {
	       while(1);
	   }
        }
没有搞懂IO映射,直接ADC_open第一个参数填的0.最后程序进入了while(1).请帮忙分析下可能是哪儿的问题,谢谢你!

 

  • 看下ADC_Config里的设置

    const ADC_Config ADC_config[CC2640R2_LAUNCHXL_ADCCOUNT] = {
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC0], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC0]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC1], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC1]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC2], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC2]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC3], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC3]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC4], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC4]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC5], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC5]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC6], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC6]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC7], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC7]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADCDCOUPL], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCDCOUPL]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADCVSS], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCVSS]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADCVDDS], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCVDDS]},
    };
    
    /*!
     *  @brief  Function to initialize the ADC peripheral
     *
     *  Function to initialize the ADC peripheral specified by the
     *  particular index value.
     *
     *  @pre    ADC_init() has been called
     *
     *  @param[in]  index     Index in the @p ADC_Config[] array.
     *  @param[in]  params    Pointer to an initialized #ADC_Params structure.
     *                        If NULL, the default #ADC_Params values are used.
     *
     *  @return An #ADC_Handle on success or NULL on error.
     *
     *  @sa     ADC_init()
     *  @sa     ADC_close()
     */
    extern ADC_Handle ADC_open(uint_least8_t index, ADC_Params *params);

  • const ADC_Config user_ADCConfig[USER_ADCCOUNT] = {
    {&ADCCC26XX_fxnTable,&userADCProjects[USER_ADC0],&userADCHwAttrs[USER_ADC0]},
    {&ADCCC26XX_fxnTable,&userADCProjects[USER_ADC1],&userADCHwAttrs[USER_ADC1]},
    {&ADCCC26XX_fxnTable,&userADCProjects[USER_ADC2],&userADCHwAttrs[USER_ADC2]},
    {&ADCCC26XX_fxnTable,&userADCProjects[USER_ADCDCOUPL],&userADCHwAttrs[USER_ADCDCOUPL]},
    {&ADCCC26XX_fxnTable,&userADCProjects[USER_ADCVSS],&userADCHwAttrs[USER_ADCVSS]},
    {&ADCCC26XX_fxnTable,&userADCProjects[USER_ADCVDDS],&userADCHwAttrs[USER_ADCVDDS]},
    };
    const ADCCC26XX_HWAttrs userADCHwAttrs[USER_ADCCOUNT] = {
    {
    //ADC0的配置
    .adcDIO = ADC_PIN0,//#define ADC_PIN0 IOID_12
    .adcCompBInput = ADC_COMPB_IN_AUXIO7,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = false,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = 0
    },
    因为之前2640R2F有比较器, 而2640R2L没有, .inputScalingEnabled由true改为false了,在2640R2L上跑不过,RHB封装DIO7-DIO14可以作为模拟引脚。
  • 能看下图中adcCC26XXHWAttrs的初始化吗,基于2640R2L的
  • 参考software-dl.ti.com/.../_a_d_c_buf_c_c26_x_x_8h.html解决。
    一个ADC映射表
    It maps a DIO to its corresponding driverlib define for the CompBInput that it is hardwired to. This table can be used to create virtual channel entries in the ADCBufCC26XX_adcChannelLut table in the board file.
  • 已经解决了吗?是引脚映射问题?