-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: support multiple transmit mailboxes #60
Comments
Advanced use of BxCanSkip if you don't need advanced usage. About transmissionSTM32 has three transmit(TX) mailboxes.
About receptionSTM32 has two receive(RX) mailboxes. |
Thank you! That seems to match what I read and gives me confidence to proceed. |
I've had much success now. Thank you for your help. I've been reading the RM0090 manual for the STM32F405 as you suggested. One thing still eludes me - how do I create an interrupt for bxCAN? I want to catch arriving messages before the three mailboxes overflow. ChatGPT only tells me how to interrupt on a pin change :( |
First of all, to write a conclusion, you cannot use bxCan interrupts with Arduino core support for STM32. The following steps should get the transmit interrupt working, but then it stops. Add this in CANInit()
Add this in Setup()
Transmit interrupts are now enabled. STM32F4 Interrupt handlers are defined with the following names.
This is a week function, so you can replace it.
This interrupt function is called when transmission is completed, but when this function ends, it becomes HALT. You can use a debugger with Arduino IDE 2.x. You can see that this function is called by setting BreakPoint to this function. It crashes when I proceed with StepOver. |
Interesting! Here's what I did MarginallyClever/Daisy-Driver-2.0-firmware@465ec3d in Arduino 2.2.1 with https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json void CANInit() {
// ...
// attach message pending interrupt method
NVIC_SetPriority(CAN1_RX_IRQn, 1);
NVIC_EnableIRQ(CAN1_RX_IRQn);
// Enable FIFO Message Pending Interrupt
CAN1->IER |= CAN_IER_FMPIE0 | CAN_IER_FMPIE1;
DEBUGLN("CAN1 interrupt enabled.");
return true;
}
int CANstate2,CANstate1;
void CAN1_RX0_IRQHandler(void) {
light.setColor(0,CANstate1,CANstate2);
CANstate2 = (CANstate2==0? 255 : 0);
CAN1->RF0R |= CAN_RF0R_RFOM0; // release FIFO
CAN1->IER |= CAN_IER_FMPIE0; // enable interrupt
}
void CAN1_RX1_IRQHandler(void) {
light.setColor(0,CANstate2,CANstate2);
CANstate1 = (CANstate1==0? 255 : 0);
CAN1->RF1R |= CAN_RF1R_RFOM1; // release FIFO
CAN1->IER |= CAN_IER_FMPIE1; // enable interrupt
} I confirm this problem case. No response from STM tells me nobody write the firmware this way because |
Does light.setColor() run correctly? |
on it's own, sure. it's just banging the pins. void LED::setColor(uint8_t r,uint8_t g,uint8_t b) {
analogWrite(PIN_PWM_RGB_R,r);
analogWrite(PIN_PWM_RGB_G,g);
analogWrite(PIN_PWM_RGB_B,b);
} in the interrupt? no. the light turns on once and then stays there. |
CAN1_RX0_IRQHandler is a C language function.
LED will turn on. |
It hated external “c”Sent from my iPhoneOn Sep 20, 2023, at 4:44 PM, nopnop2002 ***@***.***> wrote:
You need to change:
//void CAN1_RX0_IRQHandler(void) {
extern "C" void CAN1_RX0_IRQHandler(void) {
But don't work.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Any idea why HALT occurs? |
Probably the default Week function implementation included in the core library is incomplete. I think the problem can be solved by changing the interrupt vector and using your own interrupt function will solve the problem, but I don't know how to change the interrupt vector from default. STM is not proactive in resolving this issue. |
Currently sTxMailBox array appears to be hard coded to use box 0, tho (on the STM32F405) there are at least 3. I'd love to see some code that identifies an available mailbox and uses that, or warns if there are none available.
The text was updated successfully, but these errors were encountered: