Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

[lpc2000] CAN interrupt problem

[lpc2000] CAN interrupt problem

2005-04-07 by artturi

Hi

I'm using LPC2194
I have problem getting interrupt in CAN bus. Here is the parts of my 
code that has some problem don't know what.
The Bus should be configured to 1 Mb. If someone could give me a tip 
whats wrong I would be glad.

/////////////////////////
// PLL setup values are computed within the LPC include file
// It relies upon the following defines
#define FOSC                (10000000)        // Master Oscillator Freq.
#define PLL_MUL                (1)                // PLL Multiplier

// Pheripheral Bus Speed Divider
#define PBSD                1                // MUST BE 1, 2, or 4
#define PCLK                (CCLK / PBSD)    // Pheripheal Bus Clock Freq.
///////////////////////

// Interrupt Service Routines
void CAN1IRQ (void) __attribute__ ((interrupt));

//////////////////////
void CAN1IRQ (void){
        blink();
C1CMR = 0x00000004;         // Release the receive buffer
VICVectAddr = 0xFFFFFFFFL;     // Acknowledge interrupt
}

////////////////////
can1InitRx(){
PINSEL1 |= 0x00040000;         // Enable Pin 0.25 as CAN1 RX
AFMR = 0x00000002L;            // Switch off the acceptance filters
C1MOD = 0x00000001;         // Set CAN controller into reset
C1GSR = 0x00000000;            // Clear Status Register
C1BTR = 0x430005;         // 1MHz CAN bus rate
VICVectAddr0 = (unsigned int)CAN1IRQ; // Set And Enable receive interrupt
VICVectCntl0 = 0x0000003A;             // select a priority slot for a 
given interrupt p92 3a=26
VICIntEnable = 0x04000000L;         // CAN1 Rx enable interrupt
C1IER = 0x00000001;         //Enable the Receive interrupt
C1MOD = 0x00000000;         //Release CAN controller
}

//Artturi

Re: [lpc2000] CAN interrupt problem

2005-04-11 by artturi

I still haven't managed to get this working. Could someone give me 
little advice please?

//Artturi

artturi wrote:
Show quoted textHide quoted text
> Hi
>
> I'm using LPC2194
> I have problem getting interrupt in CAN bus. Here is the parts of my
> code that has some problem don't know what.
> The Bus should be configured to 1 Mb. If someone could give me a tip
> whats wrong I would be glad.
>
> /////////////////////////
> // PLL setup values are computed within the LPC include file
> // It relies upon the following defines
> #define FOSC                (10000000)        // Master Oscillator Freq.
> #define PLL_MUL                (1)                // PLL Multiplier
>
> // Pheripheral Bus Speed Divider
> #define PBSD                1                // MUST BE 1, 2, or 4
> #define PCLK                (CCLK / PBSD)    // Pheripheal Bus Clock Freq.
> ///////////////////////
>
> // Interrupt Service Routines
> void CAN1IRQ (void) __attribute__ ((interrupt));
>
> //////////////////////
> void CAN1IRQ (void){
>         blink();
> C1CMR = 0x00000004;         // Release the receive buffer
> VICVectAddr = 0xFFFFFFFFL;     // Acknowledge interrupt
> }
>
> ////////////////////
> can1InitRx(){
> PINSEL1 |= 0x00040000;         // Enable Pin 0.25 as CAN1 RX
> AFMR = 0x00000002L;            // Switch off the acceptance filters
> C1MOD = 0x00000001;         // Set CAN controller into reset
> C1GSR = 0x00000000;            // Clear Status Register
> C1BTR = 0x430005;         // 1MHz CAN bus rate
> VICVectAddr0 = (unsigned int)CAN1IRQ; // Set And Enable receive interrupt
> VICVectCntl0 = 0x0000003A;             // select a priority slot for a
> given interrupt p92 3a=26
> VICIntEnable = 0x04000000L;         // CAN1 Rx enable interrupt
> C1IER = 0x00000001;         //Enable the Receive interrupt
> C1MOD = 0x00000000;         //Release CAN controller
> }
>
> //Artturi
>
> ------------------------------------------------------------------------
> *Yahoo! Groups Links*
>
>     * To visit your group on the web, go to:
>       http://groups.yahoo.com/group/lpc2000/
>        
>     * To unsubscribe from this group, send an email to:
>       lpc2000-unsubscribe@yahoogroups.com
>       <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>        
>     * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>

Re: [lpc2000] CAN interrupt problem

2005-04-11 by Richard Duits

Hello Artturi,

To use the CAN controller you need to connect both CAN-RX and CAN-TX 
pins to a CAN tranceiver, which is connected to the CAN bus. In your 
code I see only the CAN-RX in the PINSEL.

I never figured out which status bits are connected to what interrupt 
source, so I routed all interrupts for can status and the can controller 
to the same interrupt and it works fine.

Also make sure you have the latest documentation, the first version has 
many errors in the CAN documentation.

Richard.


artturi wrote:
Show quoted textHide quoted text
> I still haven't managed to get this working. Could someone give me
> little advice please?
>
> //Artturi
>
> artturi wrote:
>
> > Hi
> >
> > I'm using LPC2194
> > I have problem getting interrupt in CAN bus. Here is the parts of my
> > code that has some problem don't know what.
> > The Bus should be configured to 1 Mb. If someone could give me a tip
> > whats wrong I would be glad.
> >
> > /////////////////////////
> > // PLL setup values are computed within the LPC include file
> > // It relies upon the following defines
> > #define FOSC                (10000000)        // Master Oscillator Freq.
> > #define PLL_MUL                (1)                // PLL Multiplier
> >
> > // Pheripheral Bus Speed Divider
> > #define PBSD                1                // MUST BE 1, 2, or 4
> > #define PCLK                (CCLK / PBSD)    // Pheripheal Bus Clock 
> Freq.
> > ///////////////////////
> >
> > // Interrupt Service Routines
> > void CAN1IRQ (void) __attribute__ ((interrupt));
> >
> > //////////////////////
> > void CAN1IRQ (void){
> >         blink();
> > C1CMR = 0x00000004;         // Release the receive buffer
> > VICVectAddr = 0xFFFFFFFFL;     // Acknowledge interrupt
> > }
> >
> > ////////////////////
> > can1InitRx(){
> > PINSEL1 |= 0x00040000;         // Enable Pin 0.25 as CAN1 RX
> > AFMR = 0x00000002L;            // Switch off the acceptance filters
> > C1MOD = 0x00000001;         // Set CAN controller into reset
> > C1GSR = 0x00000000;            // Clear Status Register
> > C1BTR = 0x430005;         // 1MHz CAN bus rate
> > VICVectAddr0 = (unsigned int)CAN1IRQ; // Set And Enable receive 
> interrupt
> > VICVectCntl0 = 0x0000003A;             // select a priority slot for a
> > given interrupt p92 3a=26
> > VICIntEnable = 0x04000000L;         // CAN1 Rx enable interrupt
> > C1IER = 0x00000001;         //Enable the Receive interrupt
> > C1MOD = 0x00000000;         //Release CAN controller
> > }
> >
> > //Artturi

Re: CAN interrupt problem

2005-04-12 by lpc2100_fan

Artturi,

did you use the CAN examples programs that can be found in the files
section?  THose do work. 
http://groups.yahoo.com/group/lpc2000/files/LPC2_CAN_Examples/


Do you really use a 10 MHz crystal and no PLL multiplier as it seems
in the code? If so, that can not work. You would need somethink like
16/32/48 MHz to run CAN at 1 Mbit. 

hth, Bob

--- In lpc2000@yahoogroups.com, artturi <artturi@s...> wrote:
> I still haven't managed to get this working. Could someone give me 
> little advice please?
> 
> //Artturi
> 
> artturi wrote:
> 
> > Hi
> >
> > I'm using LPC2194
> > I have problem getting interrupt in CAN bus. Here is the parts of my
> > code that has some problem don't know what.
> > The Bus should be configured to 1 Mb. If someone could give me a tip
> > whats wrong I would be glad.
> >
> > /////////////////////////
> > // PLL setup values are computed within the LPC include file
> > // It relies upon the following defines
> > #define FOSC                (10000000)        // Master Oscillator
Freq.
> > #define PLL_MUL                (1)                // PLL Multiplier
> >
> > // Pheripheral Bus Speed Divider
> > #define PBSD                1                // MUST BE 1, 2, or 4
> > #define PCLK                (CCLK / PBSD)    // Pheripheal Bus
Clock Freq.
> > ///////////////////////
> >
> > // Interrupt Service Routines
> > void CAN1IRQ (void) __attribute__ ((interrupt));
> >
> > //////////////////////
> > void CAN1IRQ (void){
> >         blink();
> > C1CMR = 0x00000004;         // Release the receive buffer
> > VICVectAddr = 0xFFFFFFFFL;     // Acknowledge interrupt
> > }
> >
> > ////////////////////
> > can1InitRx(){
> > PINSEL1 |= 0x00040000;         // Enable Pin 0.25 as CAN1 RX
> > AFMR = 0x00000002L;            // Switch off the acceptance filters
> > C1MOD = 0x00000001;         // Set CAN controller into reset
> > C1GSR = 0x00000000;            // Clear Status Register
> > C1BTR = 0x430005;         // 1MHz CAN bus rate
> > VICVectAddr0 = (unsigned int)CAN1IRQ; // Set And Enable receive
interrupt
> > VICVectCntl0 = 0x0000003A;             // select a priority slot for a
> > given interrupt p92 3a=26
> > VICIntEnable = 0x04000000L;         // CAN1 Rx enable interrupt
> > C1IER = 0x00000001;         //Enable the Receive interrupt
> > C1MOD = 0x00000000;         //Release CAN controller
> > }
> >
> > //Artturi
> >
> >
------------------------------------------------------------------------
Show quoted textHide quoted text
> > *Yahoo! Groups Links*
> >
> >     * To visit your group on the web, go to:
> >       http://groups.yahoo.com/group/lpc2000/
> >        
> >     * To unsubscribe from this group, send an email to:
> >       lpc2000-unsubscribe@yahoogroups.com
> >       <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
> >        
> >     * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> >       Service <http://docs.yahoo.com/info/terms/>.
> >
> >

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.