Tip / ログイン to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Translation_Bot
Community Manager
Community Manager
Community Manager
データの送信に失敗する可能性があり、送信されるとすぐに buf off に入ります。これが私のルーチンです。見てもらうのを手伝ってもらえますか? #include "Ifx_Types.h" #include "IfxCpu.h" #include "IfxScuWdt.h" IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0; #include "Ifx_Types.h" #include "IfxCan_Can.h" #include "IfxCan.h" #include "IfxCpu_Irq.h" #include "IfxPort.h" #include "Bsp.h" #define LED0 &MODULE_P13,0 #define LED1 &MODULE_P13,1 #define LED2 &MODULE_P13,2 #define LED3 &MODULE_P13,3 #define MODULE_CAN0_RAM 0xF0200000 #define NODE0_RAM_OFFSET 0x0 //#define NODE1_RAM_OFFSET 0 x1000 #define CAN_MESSAGE_TX_ID0 (uint32 )0x1234567 #define CAN_MESSAGE_RX_ID1 (uint32)0x1234561 #define CAN_MESSAGE_RX_ID2 (uint32)0x1234562 #define CAN_MESSAGE_RX_ID3 (uint32)0x1234563 #define ISR_PRIORITY_CAN_TX 2 /* CAN TX 割り込み優先度を定義します */ #define ISR_PRIORITY_CAN_RX 1 /* 定義しますCAN RX 割り込み優先度 */ #define ISR_PRIORITY_CAN22_BUSOFF 3 #define MAXIMUM_CAN_DATA_PAYLOAD 2 /* 最大古典 CAN ペイロードを 4 バイト ワードで定義 */ IFX_CONST IfxCan_Can_Pins Can00_pins = { &IfxCan_TXD00_P20_8_OUT, IfxPort_OutputMode_pushPull, // CAN00_TX &IfxCan_RXD00B_P20_7_IN, IfxPort_InputMode_pullUp, // CAN00_RX IfxPort_PadDriver_cmosAutomotiveSpeed4 } ; typedef struct { IfxCan_Can_Config canConfig; /* CAN module configuration structure */ IfxCan_Can canModule; /* CAN module handle */ IfxCan_Can_Node can00Node; /* CAN source node handle data structure */ IfxCan_Can_NodeConfig canNodeConfig; /* CAN node configuration structure */ IfxCan_Filter canFilter; /* CAN filter configuration structure */ IfxCan_Message txMsg; /* Transmitted CAN message structure */ IfxCan_Message rxMsg; /* Received CAN message structure */ uint32 txData[MAXIMUM_CAN_DATA_PAYLOAD]; /* Transmitted CAN data array */ uint32 rxData[MAXIMUM_CAN_DATA_PAYLOAD]; /* Received CAN data array */ } McmcanType; McmcanType g_mcmcan; void initCAN0(void); IFX_INTERRUPT(can22IsrBusOffHandler, 0, ISR_PRIORITY_CAN22_BUSOFF); void can22IsrBusOffHandler(void) { IfxCan_Node_clearInterruptFlag(g_mcmcan.can00Node.node, IfxCan_Interrupt_busOffStatus); initCAN0(); IfxPort_togglePin(LED1); //transmit indicator } IFX_INTERRUPT(canIsrTxHandler, 0, ISR_PRIORITY_CAN _TX); ボイド canIsrTxHandler(void) { /* Clear the "Transmission Completed" interrupt flag */ IfxCan_Node_clearInterruptFlag(g_mcmcan.can00Node.node, IfxCan_Interrupt_transmissionCompleted); IfxPort_togglePin(LED0); //transmit indicator } IFX_INTERRUPT(canIsrRxHandler, 0, ISR_PRIORITY_CAN_RX); void canIsrRxHandler(void) { /* 「専用受信バッファに保存されたメッセージ」割り込みフラグをクリアします */ IfxCan_Node_clearInterruptFlag(g_mcmcan.can00Node.node,IfxCan_Interrupt_messageStoredToDicateRxBuffer); /* 「新規データ」フラグをクリアします。「新規データ」フラグが設定されている限り、それぞれの Rx バッファーは * 受信した一致フレームからの更新に対してロックされます */ IfxCan_Node_clearRxBufferNewDataFlag(g_mcmcan.can00Node.node,g_mcmcan.canFilter.rxBufferOffset); /* 受信した CAN メッセージを読み取ります */ IfxCan_Can_readMessage(&g_mcmcan.can00Node, &g_mcmcan.rxMsg,g_mcmcan.rxData); /* 受信したデータが送信したデータと一致するかどうかを確認します */ if((g_mcmcan.rxMsg.messageId == CAN_MESSAGE_RX_ID1) && (g_mcmcan.rxData[1]== 0xEFCDAB89)) { if(g_mcmcan.rxData[0]== 0x67452301) { //send 0x IfxPort_setPinState(LED1, IfxPort_State_low); //LED ON } else { IfxPort_setPinState(LED1, IfxPort_State_high); //LED OFF } } if((g_mcmcan.rxMsg.messageId == CAN_MESSAGE_RX_ID2) && (g_mcmcan.rxData[1]== 0xEFCDAB89)) { if(g_mcmcan.rxData[0]== 0x67452302) { IfxPort_setPinState(LED2, IfxPort_State_low); } else { IfxPort_setPinState(LED2, IfxPort_State_high); } } if((g_mcmcan.rxMsg.messageId == CAN_MESSAGE_RX_ID3) && (g_mcmcan.rxData[1]== 0xEFCDAB89)) { if(g_mcmcan.rxData[0]== 0x67452303) { IfxPort_setPinState(LED3, IfxPort_State_low); } else { IfxPort_setPinState(LED3, IfxPort_State_high); } } } void initCAN0(void) { /*******CAN module configuration and initialization*******/ IfxCan_Can_initModuleConfig(&g_mcmcan.canConfig, &MODULE_CAN0); IfxCan_Can_initModule(&g_mcmcan.canModule, &g_mcmcan.canConfig); /*******CAN00 node configuration and initialization*******/ IfxCan_Can_initNodeConfig(&g_mcmcan.canNodeConfig, &g_mcmcan.canModule); g_mcmcan.canNodeConfig.nodeId = IfxCan_NodeId_0; g_mcmcan.canNodeConfig.clockSource = IfxCan_ClockSource_both; g_mcmcan.canNodeConfig.frame.type = IfxCan_FrameType_transmitAndReceive; g_mcmcan.canNodeConfig.frame.mode = IfxCan_FrameMode_standard; //Classic CAN g_mcmcan.canNodeConfig.txConfig.txMode = IfxCan_TxMode_dedicatedBuffers; g_mcmcan.canNodeConfig.txConfig.dedicatedTxBuffersNumber = 255; g_mcmcan.canNodeConfig.txConfig.txBufferDataFieldSize = IfxCan_DataFieldSize_8; g_mcmcan.canNodeConfig.rxConfig.rxMode = IfxCan_RxMode_dedicatedBuffers; g_mcmcan.canNodeConfig.rxConfig.rxBufferDataFieldSize = IfxCan_DataFieldSize_8; g_mcmcan.canNodeConfig.filterConfig.extendedListSize = 255; //Extended Frame g_mcmcan.canNodeConfig.filterConfig.messageIdLength = IfxCan_MessageIdLength_extended; g_mcmcan.canNodeConfig.messageRAM.extendedFilterListStartAddress = 0x100; //Extended Frame g_mcmcan.canNodeConfig.messageRAM.rxBuffersStartAddress = 0x200; g_mcmcan.canNodeConfig.messageRAM.txBuffersStartAddress = 0x400; g_mcmcan.canNodeConfig.messageRAM.baseAddress = MODULE_CAN0_RAM + NODE0_RAM_OFFSET; g_mcmcan.canNodeConfig.baudRate.baudrate = 500000; //500KBaud //transmit interrupt g_mcmcan.canNodeConfig.interruptConfig.transmissionCompletedEnabled = TRUE; g_mcmcan.canNodeConfig.interruptConfig.traco.priority = ISR_PRIORITY_CAN_TX; g_mcmcan.canNodeConfig.interruptConfig.traco.interruptLine = IfxCan_InterruptLine_0; g_mcmcan.canNodeConfig.interruptConfig.traco.typeOfService = IfxSrc_Tos_cpu0; //receive interrupt g_mcmcan.canNodeConfig.interruptConfig.messageStoredToDedicatedRxBufferEnabled = TRUE; g_mcmcan.canNodeConfig.interruptConfig.reint.priority = ISR_PRIORITY_CAN_RX; g_mcmcan.canNodeConfig.interruptConfig.reint.interruptLine = IfxCan_InterruptLine_1; g_mcmcan.canNodeConfig.interruptConfig.reint.typeOfService = IfxSrc_Tos_cpu0; //bus-off interrupt g_mcmcan.canNodeConfig.interruptConfig.busOffStatusEnabled = TRUE; g_mcmcan.canNodeConfig.interruptConfig.boff.priority = ISR_PRIORITY_CAN22_BUSOFF; g_mcmcan.canNodeConfig.interruptConfig.boff.interruptLine = IfxCan_InterruptLine_2; g_mcmcan.canNodeConfig.interruptConfig.boff.typeOfService = IfxSrc_Tos_cpu0; //binding pin g_mcmcan.canNodeConfig.pins = &Can00_pins; IfxCan_Can_initNode(&g_mcmcan.can00Node, &g_mcmcan.canNodeConfig); /*******CAN filter configuration and initialization*******/ g_mcmcan.canFilter.number = 0; g_mcmcan.canFilter.elementConfiguration = IfxCan_FilterElementConfiguration_storeInRxBuffer; g_mcmcan.canFilter.id1 = CAN_MESSAGE_RX_ID1; g_mcmcan.canFilter.rxBufferOffset = IfxCan_RxBufferId_0; //IfxCan_Can_setStandardFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter); IfxCan_Can_setExtendedFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter); g_mcmcan.canFilter.number = 1; g_mcmcan.canFilter.elementConfiguration = IfxCan_FilterElementConfiguration_storeInRxBuffer; g_mcmcan.canFilter.id1 = CAN_MESSAGE_RX_ID2; //g_mcmcan.canFilter.id2 = CAN_MESSAGE_RX_ID2; g_mcmcan.canFilter.rxBufferOffset = IfxCan_RxBufferId_0; //IfxCan_Can_setStandardFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter); IfxCan_Can_setExtendedFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter); g_mcmcan.canFilter.number = 2; g_mcmcan.canFilter.elementConfiguration = IfxCan_FilterElementConfiguration_storeInRxBuffer; g_mcmcan.canFilter.id1 = CAN_MESSAGE_RX_ID3; //g_mcmcan.canFilter.id2 = CAN_MESSAGE_RX_ID3; g_mcmcan.canFilter.rxBufferOffset = IfxCan_RxBufferId_0; //IfxCan_Can_setStandardFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter); IfxCan_Can_setExtendedFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter); } void initLED(void) { IfxPort_setPinMode(LED0, IfxPort_Mode_outputPushPullGeneral); /* Initialize LED port pin */ IfxPort_setPinMode(LED1, IfxPort_Mode_outputPushPullGeneral); IfxPort_setPinMode(LED2, IfxPort_Mode_outputPushPullGeneral); IfxPort_setPinMode(LED3, IfxPort_Mode_outputPushPullGeneral); IfxPort_setPinState(LED0, IfxPort_State_high); /* Turn off LED (LED is low-level active) */ IfxPort_setPinState(LED1, IfxPort_State_high); IfxPort_setPinState(LED2, IfxPort_State_high); IfxPort_setPinState(LED3, IfxPort_State_high); } void core0_main(void) { IfxCpu_enableInterrupts() ; /* !!WATCHDOG0 および SAFETY WATCHDOG ARE DISABLED HERE!! * ウォッチドッグを有効にし、必要に応じて定期的にサービスを提供します */ IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword()); IfxScuWdt_disableSafetyWatchdog(IfxScuWdt _getSa fetyWatchdogPassword()); /* CPU 同期イベントを待ちます */ IfxCpu_emitEvent(&g_cpuSyncEvent); IfxCpu_waitEvent(&g_cpuSyncEvent, 1); initLED(); //initTime(); initCAN0(); IfxCan_Can_initMessage(&g_mcmcan.txMsg); g_mcmcan.txMsg.messageId = CAN_MESSAGE_TX_ID0; g_mcmcan.txMsg.bufferNumber= 0; g_mcmcan.txMsg.dataLengthCode= IfxCan_DataLengthCode_8;//8 バイト g_mcmcan.txMsg.frameMode = IfxCan_FrameMode_standard; //クラシック CAN g_mcmcan.txMsg.messageIdLength=IfxCan_MessageIdLength_extended;//拡張フレーム g_mcmcan.txData[0]= 0x98BADCFE; g_mcmcan.txData[1]= 0x10325476; //次を受け取ります: FE DC BA 98 76 54 32 10 while(1) { while(IfxCan_Status_notSentBusy == IfxCan_Can_sendMessage(&g_mcmcan.can00Node, &g_mcmcan.txMsg, &g_mcmcan.txData[0]) ); waitTime(IfxStm_getTicksFromMilliseconds(BSP_DEFAULT_TIMER, 1000)); //ms } }

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/tc397-can-%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE%E5%A4%B1%E8%B4%A5-%E4%B8%80%E5%8F%91%E9%80%81%E5%B0%B1%E4%BC%9A%E8%BF%9B%E5%85%A5buf-off/td-p/678165

0 件の賞賛
1 解決策
Translation_Bot
Community Manager
Community Manager
Community Manager

こんにちは@andersons さん

問題の説明を再フォーマットする必要があると思いますか?上記の内容は多すぎて読むことができません。

B.R.、

ジェレミー

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/tc397-can-%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE%E5%A4%B1%E8%B4%A5-%E4%B8%80%E5%8F%91%E9%80%81%E5%B0%B1%E4%BC%9A%E8%BF%9B%E5%85%A5buf-off/m-p/678953

元の投稿で解決策を見る

0 件の賞賛
3 返答(返信)
Translation_Bot
Community Manager
Community Manager
Community Manager

こんにちは@andersons さん

問題の説明を再フォーマットする必要があると思いますか?上記の内容は多すぎて読むことができません。

B.R.、

ジェレミー

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/tc397-can-%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE%E5%A4%B1%E8%B4%A5-%E4%B8%80%E5%8F%91%E9%80%81%E5%B0%B1%E4%BC%9A%E8%BF%9B%E5%85%A5buf-off/m-p/678953

0 件の賞賛
Translation_Bot
Community Manager
Community Manager
Community Manager

こんにちは@Jeremy_Z

申し訳ありませんが、前のメッセージに気づきませんでした。問題は解決されました。 ご支援ありがとうございます。

理由は、can通信のテスト時に他のcanデバイスに接続していないのですが、canプロトコルには応答信号が必要であることがわかり、tc397が他のcanデバイスのackを検出できないため送信できないのだと思います。

よろしくお願いします

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/tc397-can-%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE%E5%A4%B1%E8%B4%A5-%E4%B8%80%E5%8F%91%E9%80%81%E5%B0%B1%E4%BC%9A%E8%BF%9B%E5%85%A5buf-off/m-p/689145

0 件の賞賛
Translation_Bot
Community Manager
Community Manager
Community Manager

こんにちは@andersons さん

問題は解決しましたか?

B.R.、

ジェレミー

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/tc397-can-%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE%E5%A4%B1%E8%B4%A5-%E4%B8%80%E5%8F%91%E9%80%81%E5%B0%B1%E4%BC%9A%E8%BF%9B%E5%85%A5buf-off/m-p/689133

0 件の賞賛