用的是BLE_UART例程,蓝牙初始化那些都没改过,添加了一段AD采集代码,然后只要运行例程里初始化的这个任务,ADC转换一两秒后就不转换了,ADC寄存器的值就一直是0了。BLE有哪些地方跟ADC冲突了吗?
void Peripheral_Init() { Peripheral_TaskID = TMOS_ProcessEventRegister(Peripheral_ProcessEvent); // // Setup the GAP Peripheral Role Profile // { // uint8_t initial_advertising_enable = TRUE; // uint16_t desired_min_interval = 6; // uint16_t desired_max_interval = 1000; // // // Set the GAP Role Parameters // GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initial_advertising_enable); // GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData), scanRspData); // GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData); // GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t), &desired_min_interval); // GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t), &desired_max_interval); // } // // Set the GAP Characteristics // GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName); // // // Set advertising interval // { // uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL; // // GAP_SetParamValue(TGAP_DISC_ADV_INT_MIN, advInt); // GAP_SetParamValue(TGAP_DISC_ADV_INT_MAX, advInt); // } // // // Setup the GAP Bond Manager // { // uint32_t passkey = 0; // passkey "000000" // uint8_t pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ; // uint8_t mitm = TRUE; // uint8_t bonding = TRUE; // uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY; // GAPBondMgr_SetParameter(GAPBOND_PERI_DEFAULT_PASSCODE, sizeof(uint32_t), &passkey); // GAPBondMgr_SetParameter(GAPBOND_PERI_PAIRING_MODE, sizeof(uint8_t), &pairMode); // GAPBondMgr_SetParameter(GAPBOND_PERI_MITM_PROTECTION, sizeof(uint8_t), &mitm); // GAPBondMgr_SetParameter(GAPBOND_PERI_IO_CAPABILITIES, sizeof(uint8_t), &ioCap); // GAPBondMgr_SetParameter(GAPBOND_PERI_BONDING_ENABLED, sizeof(uint8_t), &bonding); // } // // // Initialize GATT attributes // GGS_AddService(GATT_ALL_SERVICES); // GAP // GATTServApp_AddService(GATT_ALL_SERVICES); // GATT attributes // DevInfo_AddService(); // Device Information Service // ble_uart_add_service(on_bleuartServiceEvt); // // // Init Connection Item // peripheralInitConnItem(&peripheralConnList); // // // Register receive scan request callback // GAPRole_BroadcasterSetCB(&Broadcaster_BroadcasterCBs); // Setup a delayed profile startup tmos_set_event(Peripheral_TaskID, SBP_START_DEVICE_EVT); }
ADC配置
void ADC_Function_Init(void) { ADC_InitTypeDef ADC_InitStructure = {0}; GPIO_InitTypeDef GPIO_InitStructure = {0}; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_ADCCLKConfig(RCC_PCLK2_Div8); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_6 | GPIO_Pin_5|GPIO_Pin_7 | GPIO_Pin_0|GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); ADC_DeInit(ADC1); ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = AD_CHANNEL_NUM; ADC_Init(ADC1, &ADC_InitStructure); ADC_DMACmd(ADC1, ENABLE); ADC_Cmd(ADC1, ENABLE); ADC_BufferCmd(ADC1, DISABLE); //disable buffer ADC_ResetCalibration(ADC1); while(ADC_GetResetCalibrationStatus(ADC1)); ADC_StartCalibration(ADC1); while(ADC_GetCalibrationStatus(ADC1)); Calibrattion_Val = Get_CalibrationValue(ADC1); printf("-CalibrattionValue:%d\n", Calibrattion_Val); ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 1, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 2, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 3, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 4, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 5, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 6, ADC_SampleTime_239Cycles5); ADC_SoftwareStartConvCmd(ADC1, ENABLE); }
热门产品 :
CH339: 7端口多功能USB HUB控制器芯片