Giter Club home page Giter Club logo

Comments (2)

mbednotifications avatar mbednotifications commented on July 19, 2024

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 Reproduce

Run 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 Cause

Checking 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.

mbednotifications avatar mbednotifications commented on July 19, 2024

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 Reproduce

Run 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 Cause

Checking 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.