Micom_Electric/마이컴_원칩 2012. 7. 12. 23:00

http://nexp.tistory.com/930
인터럽트 Handler 부분 
[stm32f10x_it.c]
void USB_LP_CAN_RX0_IRQHandler(void)
{
   wIstr = USB_Istr();
  
  if(CAN_GetITStatus(CAN_IT_FMP0) == SET)
  {
    CAN_Receive(CAN_FIFO0, &gRxMessage);
  
   gFlagCanInt = 1;  
  }
}
인터럽트 발생하면CAN_Receive() 함수를 이용해 데이터를 가져오면 된다.



USB와 CAN은 동일한 인터럽트 핸들러를 공유 하므로 고려할 부분이 있는데... 일단 USB, CAN을 동시에 사용하면 문제가 있는것 같다.

메뉴얼을 살펴보니 USB와 CAN은 512-SRAM을 사용하고 있는데... 이를 동시에 사용할 수 없다고 되어 있다. 버퍼를 잘 관리해서 쓰면 불가능 하지는 않겠지만 USB드라이버 쪽을 다시 제작해야 하는 아주 큰 문제가 발생할것 같다...
The USB and CAN share a dedicated 512-byte SRAM memory for data transmission and reception, and so they cannot be used concurrently (the shared SRAM is accessed through CAN and USB exclusively). The USB and CAN can be used in the same application but not at the same time.

물론 CAN포트가 2개 있는 칩으로 하면 문제 없지만 그러면 가격이 상승된다. 저렴한 CAN to USB 장치를 만드는 것이 목적 이었기 때문에 결국 이 문제를 해결하기 위해 다른칩(LM3S5x)으로 해결해야 했다. 

posted by 털보네i
: