小弟去下載USB的3.3.0的資料庫,裡面有EVAL的Virtual COM Port程式,想要一直到我的板子上,對照了電路圖,小弟的板子不是市面上的開發板,用的IC是STM32F102R8,USB的PULL UP控制是在PB9,照原本的是設定在platform_config.h裡設定是PD9,把它修改成PB9後變成一直在卡在USB中斷那邊,後來追到stm3210b_eval.h裡的PB9有重複定義把它改成PD9,platform_config.h裡設定是PB9,但是還是卡住在USB中斷,修改的部分程式如下:
stm3210b_eval.h
#define BUTTONn 8
/**
* @brief Wakeup push-button
*/
#define WAKEUP_BUTTON_PIN GPIO_Pin_0
#define WAKEUP_BUTTON_GPIO_PORT GPIOA
#define WAKEUP_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOA
#define WAKEUP_BUTTON_EXTI_LINE EXTI_Line0
#define WAKEUP_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOA
#define WAKEUP_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource0
#define WAKEUP_BUTTON_EXTI_IRQn EXTI0_IRQn
/**
* @brief Tamper push-button
*/
#define TAMPER_BUTTON_PIN GPIO_Pin_13
#define TAMPER_BUTTON_GPIO_PORT GPIOC
#define TAMPER_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOC
#define TAMPER_BUTTON_EXTI_LINE EXTI_Line13
#define TAMPER_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOC
#define TAMPER_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource13
#define TAMPER_BUTTON_EXTI_IRQn EXTI15_10_IRQn
/**
* @brief Key push-button
*/
#define KEY_BUTTON_PIN GPIO_Pin_9
#define KEY_BUTTON_GPIO_PORT GPIOD------>B改D
#define KEY_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOD------>B改D
#define KEY_BUTTON_EXTI_LINE EXTI_Line9
#define KEY_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOD-->B改D
#define KEY_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource9
#define KEY_BUTTON_EXTI_IRQn EXTI9_5_IRQn
/**
* @brief Joystick Right push-button
*/
#define RIGHT_BUTTON_PIN GPIO_Pin_0
#define RIGHT_BUTTON_GPIO_PORT GPIOE
#define RIGHT_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOE
#define RIGHT_BUTTON_EXTI_LINE EXTI_Line0
#define RIGHT_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOE
#define RIGHT_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource0
#define RIGHT_BUTTON_EXTI_IRQn EXTI0_IRQn
/**
* @brief Joystick Left push-button
*/
#define LEFT_BUTTON_PIN GPIO_Pin_1
#define LEFT_BUTTON_GPIO_PORT GPIOE
#define LEFT_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOE
#define LEFT_BUTTON_EXTI_LINE EXTI_Line1
#define LEFT_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOE
#define LEFT_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource1
#define LEFT_BUTTON_EXTI_IRQn EXTI1_IRQn
/**
* @brief Joystick Up push-button
*/
#define UP_BUTTON_PIN GPIO_Pin_8
#define UP_BUTTON_GPIO_PORT GPIOD
#define UP_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOD
#define UP_BUTTON_EXTI_LINE EXTI_Line8
#define UP_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOD
#define UP_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource8
#define UP_BUTTON_EXTI_IRQn EXTI9_5_IRQn
/**
* @brief Joystick Down push-button
*/
#define DOWN_BUTTON_PIN GPIO_Pin_14
#define DOWN_BUTTON_GPIO_PORT GPIOD
#define DOWN_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOD
#define DOWN_BUTTON_EXTI_LINE EXTI_Line14
#define DOWN_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOD
#define DOWN_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource14
#define DOWN_BUTTON_EXTI_IRQn EXTI15_10_IRQn
/**
* @brief Joystick Sel push-button
*/
#define SEL_BUTTON_PIN GPIO_Pin_12
#define SEL_BUTTON_GPIO_PORT GPIOD
#define SEL_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOD
#define SEL_BUTTON_EXTI_LINE EXTI_Line12
#define SEL_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOD
#define SEL_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource12
#define SEL_BUTTON_EXTI_IRQn EXTI15_10_IRQn
platform_config.h
#ifdef USE_STM3210B_EVAL
#define USB_DISCONNECT GPIOB ----->D改B
#define USB_DISCONNECT_PIN GPIO_Pin_9
#define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB
----->D改B
#define EVAL_COM1_IRQHandler USART1_IRQHandler
#elif defined (USE_STM3210E_EVAL)
#define USB_DISCONNECT GPIOB
#define USB_DISCONNECT_PIN GPIO_Pin_14
#define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB
#define EVAL_COM1_IRQHandler USART1_IRQHandler
#elif defined (USE_STM3210C_EVAL)
#define USB_DISCONNECT 0
#define USB_DISCONNECT_PIN 0
#define RCC_APB2Periph_GPIO_DISCONNECT 0
#define EVAL_COM1_IRQHandler USART2_IRQHandler
main.c
int main(void)
{
Set_System();
USB_Interrupts_Config();----------->程式卡死在這邊
Set_USBClock();
USB_Init();
while (1)
{
}
}
我進去跑他是一直重複執行USB_Istr();
單步執行看他跑的情況是
void USB_Istr(void)
{
wIstr = _GetISTR();
#if (IMR_MSK & ISTR_SOF)
if (wIstr & ISTR_SOF & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_SOF);
bIntPackSOF++;
#ifdef SOF_CALLBACK
SOF_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_CTR)
if (wIstr & ISTR_CTR & wInterrupt_Mask)
{
/* servicing of the endpoint correct transfer interrupt */
/* clear of the CTR flag into the sub */
CTR_LP();---------------------------------------------------------------------------------------->第一步
#ifdef CTR_CALLBACK
CTR_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_RESET)
if (wIstr & ISTR_RESET & wInterrupt_Mask)-------------------------------------------------->第二步
{
_SetISTR((uint16_t)CLR_RESET);
Device_Property.Reset();
#ifdef RESET_CALLBACK
RESET_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_DOVR)
if (wIstr & ISTR_DOVR & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_DOVR);
#ifdef DOVR_CALLBACK
DOVR_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_ERR)
if (wIstr & ISTR_ERR & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_ERR);
#ifdef ERR_CALLBACK
ERR_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_WKUP)
if (wIstr & ISTR_WKUP & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_WKUP);
Resume(RESUME_EXTERNAL);
#ifdef WKUP_CALLBACK
WKUP_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_SUSP)
if (wIstr & ISTR_SUSP & wInterrupt_Mask)
{
/* check if SUSPEND is possible */
if (fSuspendEnabled)
{
Suspend();
}
else
{
/* if not possible then resume after xx ms */
Resume(RESUME_LATER);
}
/* clear of the ISTR bit must be done after setting of CNTR_FSUSP */
_SetISTR((uint16_t)CLR_SUSP);
#ifdef SUSP_CALLBACK
SUSP_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_ESOF)
if (wIstr & ISTR_ESOF & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_ESOF);
/* resume handling timing is made with ESOFs */
Resume(RESUME_ESOF); /* request without change of the machine state */
#ifdef ESOF_CALLBACK
ESOF_Callback();
#endif
}
#endif
}
------------------------------------------------------------------------------------------------------------------->第三步
第二步到第三步之間都沒有進去就結束了,下一次再從第一步來,就這樣卡死在這
拜託大大幫我看看是什麼問題
此帖出自
小平头技术问答
一周热门 更多>