реклама на сайте
подробности

 
 
 
Reply to this topicStart new topic
> прерывание от CAN в LPC2129, запарился уже...
Punk
сообщение Feb 28 2008, 05:46
Сообщение #1


Местный
***

Группа: Участник
Сообщений: 242
Регистрация: 19-06-06
Из: Новосибирск
Пользователь №: 18 167



Привет! Помогите плз, кто в теме. Не могу примерчик из 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){};
}
Go to the top of the page
 
+Quote Post
KRS
сообщение Feb 28 2008, 07:31
Сообщение #2


Профессионал
*****

Группа: Модераторы
Сообщений: 1 951
Регистрация: 27-08-04
Из: Санкт-Петербург
Пользователь №: 555



А вообще прерывания у вас работают?
Go to the top of the page
 
+Quote Post
Punk
сообщение Feb 28 2008, 08:03
Сообщение #3


Местный
***

Группа: Участник
Сообщений: 242
Регистрация: 19-06-06
Из: Новосибирск
Пользователь №: 18 167



Цитата(KRS @ Feb 28 2008, 10:31) *
А вообще прерывания у вас работают?

Нет. Не работают=( загрузил простой пример с этого же диска с внешним прерыванием и не фига не работает=(((((
Go to the top of the page
 
+Quote Post
KRS
сообщение Feb 28 2008, 08:29
Сообщение #4


Профессионал
*****

Группа: Модераторы
Сообщений: 1 951
Регистрация: 27-08-04
Из: Санкт-Петербург
Пользователь №: 555



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

Я с ARM GCC почти не работал, но у вас не видно глобального разрешения прерываний (в CPSR регистре).
И собственно самого обработчика IRQ (что то типа ldr PC,[PC,#0xFFFFF030 - (.+8)] //VICVectAddr) который переходит по адресу который подскажет контроллер прерываний.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 18th July 2025 - 08:05
Рейтинг@Mail.ru


Страница сгенерированна за 0.01392 секунд с 7
ELECTRONIX ©2004-2016