2013-03-16 07:42 PM
Hello...
Now i design USB Host System. In the system there are 2 button interrupts, USB Host Interrupt. I use STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0 libraries and stm32f105...In the system, i sometimes disable and enable button interrupts when i enter interrupt routine of button and when i enter USB Process function of USB libraries... i use system clock 8MHz for my system and PLL for my USB Host Clock...NVIC priorities is as follows: 1- Button interrupts(for each two) : NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;2- my USB board support package configuration : Timer : NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; USB Global Int. NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;And my button enable disable code is follows : void STM32_UP_Button_OnOff(FunctionalState NewState){ EXTI_InitTypeDef EXTI_InitStructure; /* Initializes the EXTI_InitStructure */ EXTI_StructInit(&EXTI_InitStructure); EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Line = UP_BUTTON_EXTI_LINE; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //EXTI_ClearITPendingBit(UP_BUTTON_EXTI_LINE ); /* Disable the DOWN_BUTTON_EXTI_LINE on falling edge */ if(NewState == DISABLE) { EXTI_InitStructure.EXTI_LineCmd = DISABLE; } /* Enable the EXTI DOWN_BUTTON_EXTI_LINE on falling edge */ else { /* Clear the the DOWN_BUTTON_EXTI_LINE interrupt pending bit */ //E EXTI_InitStructure.EXTI_LineCmd = ENABLE; } EXTI_Init(&EXTI_InitStructure); }The problem is that when program works in USBH_USR_MSC_Application function, the button enable/disable does not work even if i see that External Interrupt Mask Register sets register in Keil... i can not enter button interrupts even if i enable button interrupts in USBH_USR_MSC_Application function? i want to change my enable, disable status in this function but i could not... Thanks in advanceBest regards #stm32-usb-host2013-03-18 08:56 AM
application works with battery and i must make this low power... when i do not need USB port, i close as follows...
void USB_CLOSE_ALL(void){// USB_OTG_BSP_DisableInterrupt(&USB_OTG_Core);// USBH_DeInit(&USB_OTG_Core,&USB_Host);// USB_OTG_BSP_DriveVBUS(0,0);// USB_OTG_BSP_DeInit(&USB_OTG_Core); USB_OTG_BSP_DisableInterrupt(0);// USBH_DeInit(&USB_OTG_Core,&USB_Host); USB_OTG_BSP_DriveVBUS(0,0);// USB_OTG_BSP_DeInit(0); Main_Data.USBWriteFlag = 0;}i am debugging with st debugger in Keil... and i observe on LCD screen sometimes... and my buttons have debouncing circuits and debouncing software... i used this app. in the past now i change to usb application... if i open VBUS forever, my battery life will not be good... Thanks in advance...2013-03-18 09:02 AM
Why must EXTI interrupts by constantly enabled/disabled? How does this relate to VBUS?
2013-03-18 09:06 AM
sorry i think i did not understand exactly.
you mean that i must poll buttons when i poll USB all the time in while loop?But i want to use WFI for low power application?Thanks in advance...2013-03-18 09:34 AM
hi,
when i use usb functions, i disable user actions for interrupting usb process, after finishing writing txt file to disk, i close all usb functions and ports for low power, and again i enable user actions for further process...At the same time, i used WFI for low power. But i think i must change design for polling system with timer?...2013-03-18 01:00 PM
Disabling the interrupt and powering off the device may not be enough.
This leaves the USB stack in a weird state. It might not come back up.you may also want to call USB_Deinit, and then USB_Init when coming out of low power.since there is a USB_OTG_BSP_EnableInterruptyou should create your own USB_OTG_BSP_DisableInterrupt in the BSP just to be consistant. (Actually there should be such a function)the stack also uses timer 2, and that has no shut off in the BSPSo, it looks like there never was a requirement that the USB OTG Host to go into any power saving mode.to be safe, you might want to ask ST support rather than ask in a user forum. I just took a quick look at the code and these are things I see.2013-03-18 02:49 PM
Thank you. I looked code... There are Init functions for USB stack and User Init functions... and code works in state diagrams... when you call USBH_Initagain, it initalizes again all values to default values... and actually there is not disable interrupt functions in library but i made for my application... When i develop some application for STM3210C eval board, my usb enable and disable configurations works, but when i develop for my private design, there are some problems. Now some flash disks work, some do not work. But they work on eval board.. I use 100mA power regulator... Could this problem happen because of this regulator? because when i write a txt file to usb stick, some flash disk stops when they reach f_close(&file); line. or i can not sometimes save some data to disk...i can creat only txt files not with informations...
2013-03-18 04:44 PM
USB device may only draw up to 100ma when enumerating. But during enumeration they may request more power, up to 5 UL (unit loads @ 100ma per UL).
They power up, enumerate, request, for example 2.5 UL, you can only deliver 1 UL, they switch on extra circuits, then brown out, over current, reset, hang up, who knows? Not nice, you not deliver power they request. You are the Host, big bad powerful, must supply device with what it wants, or shut it off if it requests too much. Shut off is legal. Not nice, but legal, USB spec says you have to inform user of why device will not be enumerated.USB spec says you have to provide 5UL (500ma) You need big battery to support different type thumb drives or shut them off.2013-03-19 04:12 PM
Yes, i saw today that i need to change my regulator... but i think i saw a new problem, and i will start a new thread...
Thanks in advance...Best regards