會員登陸
帳號:

密碼:

記住我



忘記密碼?

現在註冊!
網站導航
最新下載
訪問統計 (自2012/5/3)


正在流覽:   1 名訪客





PIC32MX795F512L CAN資料無法使用中斷接收
新會員
註冊日期:
2017/03/26 15:47
所屬群組:
註冊會員
文章: 2
等級: 1; EXP: 2
HP : 0 / 0
MP : 0 / 1
離線
請問版上各位先進
我使用的是PIC32MX795F512L USB Starter kit II,透過Harmony產生FreeeRTOS、UART和CAN的程式碼與設定。目前遇到的問題是,透過CAN BUS analyzer所發送的資料要連續發送好幾次才能接收到資料(大概三次左右)。檢查後發現修改vTaskDelay(50 / portTICK_PERIOD_MS)為vTaskDelay(1 / portTICK_PERIOD_MS)即可解決,但是這樣就變成比較像是輪詢的方式。

已經有確認過Harmonoy Configura和DRV_CAN0_Initialize裡面都是有設定為中斷的,如下所示:

void DRV_CAN0_Initialize
(void)
{    

    
/* Switch the CAN module ON */
    
PLIB_CAN_Enable(CAN_ID_1);
    
    
/* Switch the CAN module to Configuration mode. Wait until the switch is complete */
    
PLIB_CAN_OperationModeSelect(CAN_ID_1, CAN_CONFIGURATION_MODE);
    while(
PLIB_CAN_OperationModeGet(CAN_ID_1) != CAN_CONFIGURATION_MODE);

    
PLIB_CAN_PhaseSegment2LengthFreelyProgrammableEnable(CAN_ID_1);

    
//Set the Baud rate to 1000 kbps
    
PLIB_CAN_PropagationTimeSegmentSet(CAN_ID_1, 1-1);
    
PLIB_CAN_PhaseSegment1LengthSet(CAN_ID_1, 3-1);
    
PLIB_CAN_PhaseSegment2LengthSet(CAN_ID_1, 3-1);
    
PLIB_CAN_SyncJumpWidthSet(CAN_ID_1, 1-1);
    
PLIB_CAN_BaudRatePrescaleSet(CAN_ID_1, 4); // set to 1 higher then ECAN tool


    /* Assign the buffer area to the CAN module.
      In this case assign enough memory for 2
      channels, each with 8 message buffers.*/
     
PLIB_CAN_MemoryBufferAssign(CAN_ID_1, can_message_buffer0);

     
/* Configure CAN_ID_1 Channel for CAN_TX_RTR_DISABLED operation. Allocate 1 message buffer, and assign low medium priority for transmissions. */              
     
PLIB_CAN_ChannelForTransmitSet(CAN_ID_1, CAN_CHANNEL0, 1, CAN_TX_RTR_DISABLED, CAN_LOW_MEDIUM_PRIORITY);
     
/* Configure CAN_ID_1 Channel for CAN_RX_FULL_RECEIVE operation. Allocate 1 message buffer, and assign low medium priority for transmissions. */            
     
PLIB_CAN_ChannelForReceiveSet(CAN_ID_1, CAN_CHANNEL1, 1, CAN_RX_FULL_RECEIVE);
     
PLIB_CAN_FilterToChannelLink(CAN_ID_1, CAN_FILTER0, CAN_FILTER_MASK0, CAN_CHANNEL1);
     
PLIB_CAN_ChannelEventEnable(CAN_ID_1, CAN_CHANNEL1, CAN_TX_CHANNEL_NOT_FULL);


     
PLIB_CAN_FilterConfigure(CAN_ID_1, CAN_FILTER0, 0x0000, CAN_SID);
     
PLIB_CAN_FilterEnable(CAN_ID_1, CAN_FILTER0);

     
PLIB_CAN_FilterMaskConfigure(CAN_ID_1, CAN_FILTER_MASK0, 0x0, CAN_SID, CAN_FILTER_MASK_IDE_TYPE);

    
/* Switch the CAN module to Normal mode. Wait until the switch is complete */
    
PLIB_CAN_OperationModeSelect(CAN_ID_1, CAN_NORMAL_MODE);
    while(
PLIB_CAN_OperationModeGet(CAN_ID_1) != CAN_NORMAL_MODE);

    
PLIB_CAN_ModuleEventEnable(CAN_ID_1 , 0|CAN_RX_EVENT);  


    
/* Setup CAN_ID_1 Interrupt */
    
PLIB_INT_SourceEnable(INT_ID_0,INT_SOURCE_CAN_1);
    
PLIB_INT_VectorPrioritySet(INT_ID_0,INT_VECTOR_CAN1, INT_PRIORITY_LEVEL6);
    
PLIB_INT_VectorSubPrioritySet(INT_ID_0,INT_VECTOR_CAN1, INT_SUBPRIORITY_LEVEL1);
}


但是用if((PLIB_CAN_ModuleEventGet(CAN_ID_1) & (CAN_RX_EVENT)) == true)進行判斷卻遲遲無法成立。
請問是什麼問題呢?謝謝

2017/12/21 22:10
轉換PDF檔 列印






無法在此發表文章
可以在此觀看文章
無法回覆文章
無法編輯自己的文章
無法刪除自己的文章
無法發起投票調查
無法在此投票
無法上傳附加檔案
無法不經審核直接發表文章

[進階搜尋]


搜尋
Microchip連結

網頁捷徑
2018 Winter Elite 報名
教育訓練
其它網站連結
電話: 02-25000405
產品技術問題產品技術支援專線:0800-717718 台北02-25088600 新竹03-5778366 Ext. 8600 高雄07-2137830 MicrochipDIRECT 專線: 07-2137830
Powered by XOOPS © 2001-2012 The XOOPS Project