0
votes

I'm trying to run Virtual_COM_Port from STM32_USB-FS-Device_Lib_V4.0.0. I'm using IAR 7.3. Everything buld ok, but not run usb. I started use debugger. In the function

void USB_Init(void)
{
  pInformation = &Device_Info;
  pInformation->ControlState = 2;
  pProperty = &Device_Property;
  pUser_Standard_Requests = &User_Standard_Requests;
  /* Initialize devices one by one */
  pProperty->Init();
}

on line pProperty = &Device_Property; the debugger jumps to the exception handler HardFault_Handler. What could be the problem? Problem whith IAR or some settings?

1

1 Answers

0
votes

You are accesing memmory you shouldn't. Hardfault_handler by default catches all exceptions, configurable fault exceptions are disabled. Try turning on the MemManage_fault:

SCB->CHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;

//Set the priority of the MemManage fault (using CMSIS):

NVIC_SetPriority(MemoryManagement_IRQn, *priority*);

//Default name for MemManage fault function is:
void MemManage_Handler(void);

After this your hardfault will probably turn into MemManage_fault. Not much, but it gives you a better idea of what you are dealing with.

Also see this link for debugging hardfaults on iar.

I can't be sure without seeing where you set the Device_Property variable but double check that it is OK to give it's memory address to something else.