Comments (2)
I assume that this can be fixed by first checking if the CAN peripheral is
active,
Something similar is happening here:
// Have to check that the CAN block is active before reading the Interrupt
// Control Register, or the mbed hangs
void can_irq_n() {
uint32_t icr;
if(LPC_SC->PCONP & (1 << 13)) {
icr = LPC_CAN1->ICR & 0x1FF;
can_irq(icr, 0);
}
if(LPC_SC->PCONP & (1 << 14)) {
icr = LPC_CAN2->ICR & 0x1FF;
can_irq(icr, 1);
}
}
I don't have the hardware available now but I could look at it later this
week if nobody cares to beat me to it.
On Friday, September 6, 2013 11:55:20 AM UTC-7, Richard Low wrote:
The Environment
- Mbed LPC1768 on an Embedded Artists base board.
- LPCXpresso v5.2.4 [Build 2122].
- Using CAN2, LEDs and serial I/O interfaces.
The Problem
Hardfault interrupt on LPC1768 when attaching a callback function to a CAN
object and only one CAN object is defined.
How to ReproduceRun the following app on an mbed LPC1768 . Note the blue LEDs of death as
HardFault_Handler() is called.#include "mbed.h"
BusOut myleds(LED1, LED2, LED3, LED4);
CAN can2(p30, p29);
bool got_message = false;extern "C" void HardFault_Handler ()
{
error("Hit HardFault handler!\r\n");
}void can_callback()
{
got_message = true;
}int main()
{
CANMessage msg;printf("main()\n"); can2.attach(can_callback, CAN::RxIrq); int i = 0; while(1) { printf("loop()\n"); if (got_message) { got_message = false; can2.read(msg); printf("Message received: %d\n", msg.data[0]); } wait(0.2); myleds = i++; i %= 16; }
}
The Workaround
Create a second unused CAN object
CAN can1(p9, p10);
and run the app again. The app now works OK.
The CauseChecking IER on both CAN peripheral modules when only one of them is
enabled causes a hard fault.The error is in function can_irq_set(), at line 167 of file
…/mbed/targets/hal/TARGET_NXP/TARGET_LPC176x/can_api.chttps://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/can_api.c
.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/56
.
from mbed-os.
Fixed and verified that it works by modifying the 'can_interrupt' testcase.
#63
On Sunday, September 8, 2013 7:15:23 PM UTC-7, Joris wrote:
I assume that this can be fixed by first checking if the CAN peripheral is
active,Something similar is happening here:
// Have to check that the CAN block is active before reading the Interrupt
// Control Register, or the mbed hangs
void can_irq_n() {
uint32_t icr;if(LPC_SC->PCONP & (1 << 13)) { icr = LPC_CAN1->ICR & 0x1FF; can_irq(icr, 0); } if(LPC_SC->PCONP & (1 << 14)) { icr = LPC_CAN2->ICR & 0x1FF; can_irq(icr, 1); }
}
I don't have the hardware available now but I could look at it later this
week if nobody cares to beat me to it.On Friday, September 6, 2013 11:55:20 AM UTC-7, Richard Low wrote:
The Environment
- Mbed LPC1768 on an Embedded Artists base board.
- LPCXpresso v5.2.4 [Build 2122].
- Using CAN2, LEDs and serial I/O interfaces.
The Problem
Hardfault interrupt on LPC1768 when attaching a callback function to a
CAN object and only one CAN object is defined.
How to ReproduceRun the following app on an mbed LPC1768 . Note the blue LEDs of death as
HardFault_Handler() is called.#include "mbed.h"
BusOut myleds(LED1, LED2, LED3, LED4);
CAN can2(p30, p29);
bool got_message = false;extern "C" void HardFault_Handler ()
{
error("Hit HardFault handler!\r\n");
}void can_callback()
{
got_message = true;
}int main()
{
CANMessage msg;printf("main()\n"); can2.attach(can_callback, CAN::RxIrq); int i = 0; while(1) { printf("loop()\n"); if (got_message) { got_message = false; can2.read(msg); printf("Message received: %d\n", msg.data[0]); } wait(0.2); myleds = i++; i %= 16; }
}
The Workaround
Create a second unused CAN object
CAN can1(p9, p10);
and run the app again. The app now works OK.
The CauseChecking IER on both CAN peripheral modules when only one of them is
enabled causes a hard fault.The error is in function can_irq_set(), at line 167 of file
…/mbed/targets/hal/TARGET_NXP/TARGET_LPC176x/can_api.chttps://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/can_api.c
.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/56
.
from mbed-os.
Related Issues (20)
- STM32WL Deep Sleep STOP1 over consumption HOT 2
- TARGET_STM: masking logic for CAN rx interrupt is wrong HOT 2
- Buffer overflow vulnerablilty in MbedOS BLE Cordio stack HOT 2
- STM32WL USART2@2400 not working with every device HOT 6
- STM32WL System Clock differs at boot/reset and after deepsleep HOT 2
- Mbed CLI 2 USB no such file or directory HOT 2
- mbed-tools deploy is limiting the git fetch specification HOT 2
- STM32_gen_peripheralPins.py chrashing after generating pinmaps HOT 3
- Linking with error: "cannot move location counter backwards" HOT 1
- BLE start routine freezes when the event_queue dispatching inside mbed-os-ble-utils moved to a thread HOT 1
- Include directive issue with BLE API HOT 1
- PD_14 is not labeled as a SPI CS pin for Nucleo-F413ZH HOT 5
- time(NULL) not returning real RTC value after reboot HOT 1
- PC_13 is unlisted HOT 2
- TARGET_STM32F303xC: SetSysClock() missing HOT 2
- Update hidapi used for non-Linux platforms HOT 2
- Flashing Controller from Docker Container HOT 2
- mbed::CircularBuffer interrupt safe but not thread safe? HOT 2
- STM32 I2CSlave race condition causing timeouts
- LoRaWAN no OTAA Uplink on AS923 region STM32WL HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mbed-os.