roboforum.ru

Технический форум по робототехнике.

Не понимаю как работает прерывание от CAN

ARM7, ARM9, ARM11 etc.

Не понимаю как работает прерывание от CAN

Сообщение arzamas1988 » 28 мар 2012, 16:35

Всем привет! Раскуриваю пример от IARа для LM3S8962. Не могу сообразить как работает прерывание от CAN .
Вот пример CAN device FIFO mode example . This application uses the CAN controller in FIFO mode to communicate with the CAN FIFO mode example program that is running on the main board .
Так вот. При каких условиях он переходит к обработке
Код: Выделить всёРазвернуть
CANIntHandler()
?
Код в скрепке.
Тут лишь приведу код для интересующей функции

Код: Выделить всёРазвернуть
//*****************************************************************************
//
// The CAN controller interrupt handler.
//
//*****************************************************************************
void
CANIntHandler(void)
{
    unsigned long ulStatus;

    //
    // Find the cause of the interrupt, if it is a status interrupt then just
    // acknowledge the interrupt by reading the status register.
    //
    ulStatus = CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE);

    //
    // The first eight message objects make up the Transmit message FIFO.
    //
    if(ulStatus <= 8)
    {
        //
        // Increment the number of bytes transmitted.
        //
        g_sCAN.ulBytesTransmitted += 8;
    }
    //
    // The second eight message objects make up the Receive message FIFO.
    //
    else if((ulStatus > 8) && (ulStatus <= 16))
    {
        //
        // Read the data out and acknowledge that it was read.
        //
        CANMessageGet(CAN0_BASE, ulStatus, &g_sCAN.MsgObjectRx, 1);

        //
        // Advance the read pointer.
        //
        g_sCAN.MsgObjectRx.pucMsgData += 8;

        //
        // Decrement the expected bytes remaining.
        //
        g_sCAN.ulBytesRemaining -= 8;
    }
    else
    {
        //
        // This was a status interrupt so read the current status to
        // clear the interrupt and return.
        //
        CANStatusGet(CAN0_BASE, CAN_STS_CONTROL);
    }

    //
    // Acknowledge the CAN controller interrupt has been handled.
    //
    CANIntClear(CAN0_BASE, ulStatus);
}
Вложения
CAN.c
Исходник
(16.44 КиБ) Скачиваний: 376
arzamas1988
 
Сообщения: 1
Зарегистрирован: 28 мар 2012, 07:34

Re: Не понимаю как работает прерывание от CAN

Сообщение dccharacter » 28 мар 2012, 17:08

Код: Выделить всёРазвернуть
//
    // Enable interrupts from CAN controller.
    //
    CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR);

    //
    // Enable interrupts for the CAN in the NVIC.
    //
    IntEnable(INT_CAN0);

    //
    // Enable processor interrupts.
    //
    IntMasterEnable();
Мой волшебник это я сам. Всю архитектуру программы придумал лично, а ребята помогли воплотить её. Я бы и сам мог написать, но лень учить язык и его конструкции.
Аватара пользователя
dccharacter
 
Сообщения: 4995
Зарегистрирован: 10 дек 2010, 13:16
Откуда: Красногорск МО
прог. языки: C, Python, wiring/processing
ФИО: Андрей


Вернуться в ARM

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0

cron