Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: прерывание от CAN в LPC2129
Форум разработчиков электроники ELECTRONIX.ru > Микроконтроллеры (MCs) > ARM
Punk
Привет! Помогите плз, кто в теме. Не могу примерчик из Keil запустить - прерывние CAN упорно не хочет работать. Компилятор GCC.
Заранее спасибо.


Код
#include <LPC21xx.H>
//LED on/off functions ***************/
void GREEN_ON(void)
{
IOCLR0=0x00002000;
}  
void GREEN_OFF(void)
{
IOSET0=0x00002000;
}


void CAN2IRQ (void) __attribute__ ((interrupt("IRQ")));                                //Declare the RX IRQ
//unsigned *FilterPtr;

int main(void)
{
IODIR1             =     0x00FF0000;            //PORT1 all pins OUT
IODIR0             =     0xffffffff;              //PORT0 all pins OUT
IOSET0=0xFFFFFFFF;                        //PORT0 all pins in 1

VPBDIV                 =     0x00000001;                        //Set PClk to 60Mhz
IODIR1                 =     0x00FF0000;                     // set all ports to output

PINSEL1     |=         0x00014000;            //Enable Pin 0.25 as CAN1 RX
C2MOD                 =     0x00000001;                        //Set CAN controller into reset
C2BTR         =         0x006B001D;            //100                        //Set bit timing to 125k
C2IER                =    0x00000001;                        //Enable the Receive interrupt
VICVectCntl0         =     0x0000003A;                      //select a priority slot for a given interrupt
VICVectAddr0         =     (unsigned)CAN2IRQ;                //pass the address of the IRQ into the VIC slot
VICIntEnable         =     0x04000000;                        //enable interrupt
AFMR                =    0x00000001;                        //Disable the Acceptance filters to allow setup of the table
/*Fi/*lterPtr            =     (unsigned)0xE0038000;                //Set pointer to start of acceptance filter menory
*FilterPtr            =    0x20012002;                        //Write values to the Standard acceptance filter table
FilterPtr++;                                            //Increment pointer by four bytes
*FilterPtr            =    0x20032004;                        //Write next two filter values
SFF_sa                =    0x00000000;                         //Set start address of Standard table
SFF_GRP_sa            =    0x00000008;                        //Set start address of Standard group table
EFF_sa                =    0x00000008;                        //Set start address of Extended table
EFF_GRP_sa            =    0x00000008;                        //Set start address of Extended group table
ENDofTable            =    0x00000008;                        //Set end of table address
AFMR            =    0x00000000;    */                    //Enable Acceptance filters
C2MOD                 =     0x00000000;                        //Release CAN controller
IOCLR1                 =     0xffffffff;                        //clear output pins
while(1)

{
;//waiting interrupt
}

}

void CAN2IRQ (void)    
{

GREEN_OFF();                            //set output pins
C1CMR                 =    0x00000004;                     //release the recieve buffer
VICVectAddr         =     0x00000000;                        //Signal the end of interrupt
while(1){};
}
KRS
А вообще прерывания у вас работают?
Punk
Цитата(KRS @ Feb 28 2008, 10:31) *
А вообще прерывания у вас работают?

Нет. Не работают=( загрузил простой пример с этого же диска с внешним прерыванием и не фига не работает=(((((
KRS
Цитата(Punk @ Feb 28 2008, 11:03) *
Нет. Не работают=( загрузил простой пример с этого же диска с внешним прерыванием и не фига не работает=(((((

Я с ARM GCC почти не работал, но у вас не видно глобального разрешения прерываний (в CPSR регистре).
И собственно самого обработчика IRQ (что то типа ldr PC,[PC,#0xFFFFF030 - (.+8)] //VICVectAddr) который переходит по адресу который подскажет контроллер прерываний.
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Invision Power Board © 2001-2025 Invision Power Services, Inc.