HI again,
I have been trying to learn programming using the LPC2148.
Thanks to all the people who replied and helped with my ADC code.
I am taking the help of some example codes i found online. but with regard to
SPI there doesn't seem to be any examples around. although i found one that
interfaces SPI to SD card. it was a little difficult to understand. i would like
a generalized code on using SPI.
i am not asking you to give me the code.. if anyone could suggest me on the
various functions that i should write and the process flow. like in ADC i had to
write two functions
1.initialization the control register
2.then i had to read the data register.
i'll give it a try and get back to you for your suggestions.
also any suggestions or tips on things to keep an eye out for while using
UART.
Thanks for reading!
interfacing using SPI on LPC2148
Started by ●August 28, 2011
Reply by ●August 28, 20112011-08-28
On Sun, 2011-08-28 at 14:26 +0000, lucky_suhas wrote:
> i am not asking you to give me the code.. if anyone could suggest me
> on the various functions that i should write and the process flow.
Hi,
Almost on the bottom of this page :
http://www.nxp.com/#/pip/pip=[pip=LPC2141_42_44_46_48]|
pp=[t=pip,i=LPC2141_42_44_46_48]
you will find this link "LPC2xxx SPI master code example" :
http://www.nxp.com/documents/other/MACC06001_LPC2000_SPI.pdf
There is more what you might want to look at.
roelof
> i am not asking you to give me the code.. if anyone could suggest me
> on the various functions that i should write and the process flow.
Hi,
Almost on the bottom of this page :
http://www.nxp.com/#/pip/pip=[pip=LPC2141_42_44_46_48]|
pp=[t=pip,i=LPC2141_42_44_46_48]
you will find this link "LPC2xxx SPI master code example" :
http://www.nxp.com/documents/other/MACC06001_LPC2000_SPI.pdf
There is more what you might want to look at.
roelof
Reply by ●August 28, 20112011-08-28
--- In l..., "lucky_suhas" wrote:
>
> HI again,
>
> I have been trying to learn programming using the LPC2148.
> Thanks to all the people who replied and helped with my ADC code.
> I am taking the help of some example codes i found online. but with regard to SPI there doesn't seem to be any examples around. although i found one that interfaces SPI to SD card. it was a little difficult to understand. i would like a generalized code on using SPI.
>
> i am not asking you to give me the code.. if anyone could suggest me on the various functions that i should write and the process flow. like in ADC i had to write two functions
> 1.initialization the control register
> 2.then i had to read the data register.
>
> i'll give it a try and get back to you for your suggestions.
>
> also any suggestions or tips on things to keep an eye out for while using UART.
> Thanks for reading!
>
Everything you could possibly need to know about the LPC2148 is available at www.jcwren.com/arm
Much of the code is wrapped around FreeRTOS (a real-time operating system) but you can easily see how each peripheral is used. JC did a great job with this code.
I use it for reference whenever I begin a project with the LPC2148.
Richard
>
> HI again,
>
> I have been trying to learn programming using the LPC2148.
> Thanks to all the people who replied and helped with my ADC code.
> I am taking the help of some example codes i found online. but with regard to SPI there doesn't seem to be any examples around. although i found one that interfaces SPI to SD card. it was a little difficult to understand. i would like a generalized code on using SPI.
>
> i am not asking you to give me the code.. if anyone could suggest me on the various functions that i should write and the process flow. like in ADC i had to write two functions
> 1.initialization the control register
> 2.then i had to read the data register.
>
> i'll give it a try and get back to you for your suggestions.
>
> also any suggestions or tips on things to keep an eye out for while using UART.
> Thanks for reading!
>
Everything you could possibly need to know about the LPC2148 is available at www.jcwren.com/arm
Much of the code is wrapped around FreeRTOS (a real-time operating system) but you can easily see how each peripheral is used. JC did a great job with this code.
I use it for reference whenever I begin a project with the LPC2148.
Richard
Reply by ●August 28, 20112011-08-28
--- In l..., "lucky_suhas" wrote:
>
> HI again,
>
> I have been trying to learn programming using the LPC2148.
> Thanks to all the people who replied and helped with my ADC code.
> I am taking the help of some example codes i found online. but with regard to SPI there doesn't seem to be any examples around. although i found one that interfaces SPI to SD card. it was a little difficult to understand. i would like a generalized code on using SPI.
>
> i am not asking you to give me the code.. if anyone could suggest me on the various functions that i should write and the process flow. like in ADC i had to write two functions
> 1.initialization the control register
> 2.then i had to read the data register.
For SPI to work, you send a byte or short (8 or 16 bit) out while the hardware simultaneously clocks in a similar data item.
The following code is set up for 16 bit transfers. SPI0_send sends out a 16 bit unsigned short and returns the unsigned short that was clocked in.
#include "lpc214x.h"
#include "spi.h"
/*
* P0.4 => SCK connect to AD7327 SCLK
* P0.5 => MISO connect to AD7327 DOUT
* P0.6 => MOSI connect to AD7327 DIN
* P0.7 => SSEL connect to AD7327 CS'
*/
#define SSEL (1 << 7)
#define SPI_SPIE (0x00000080)
#define SPI_LSBF (0x00000040)
#define SPI_MSTR (0x00000020)
#define SPI_CPOL (0x00000010)
#define SPI_CPHA (0x00000008)
#define SPI_BitEnable (0x00000004)
#define SPI_Bits (0x00000000)
#define SPI_SPIF (0x00000080)
#define SPI_DIVIDER (8)
/*
* Set up SPI0 as a master with CPOL = 1, CPHA = 0 and 16 bit transfers.
* Force P0.7 to GPIO, set it for output and set it high
*/
void SPI0_init(void)
{
PINSEL0 |= 0x00001500;
PINSEL0 &= ~0x0000C000;
IOSET0 = SSEL;
IODIR0 |= SSEL;
S0SPCR = SPI_MSTR | SPI_CPOL | SPI_BitEnable | SPI_Bits;
S0SPCCR = SPI_DIVIDER;
}
/*
* Send value to ADC and return value shifted in.
*/
unsigned short SPI0_Send(const unsigned short value)
{
IOCLR0 = SSEL;
S0SPDR = value;
while (!(S0SPSR & SPI_SPIF))
;
IOSET0 = SSEL;
return (S0SPDR);
}
You can always just connect MOSI and MISO externally (a jumper wire) and test by looking at what is received versus what it sent. They should be identical.
Richard
>
> HI again,
>
> I have been trying to learn programming using the LPC2148.
> Thanks to all the people who replied and helped with my ADC code.
> I am taking the help of some example codes i found online. but with regard to SPI there doesn't seem to be any examples around. although i found one that interfaces SPI to SD card. it was a little difficult to understand. i would like a generalized code on using SPI.
>
> i am not asking you to give me the code.. if anyone could suggest me on the various functions that i should write and the process flow. like in ADC i had to write two functions
> 1.initialization the control register
> 2.then i had to read the data register.
For SPI to work, you send a byte or short (8 or 16 bit) out while the hardware simultaneously clocks in a similar data item.
The following code is set up for 16 bit transfers. SPI0_send sends out a 16 bit unsigned short and returns the unsigned short that was clocked in.
#include "lpc214x.h"
#include "spi.h"
/*
* P0.4 => SCK connect to AD7327 SCLK
* P0.5 => MISO connect to AD7327 DOUT
* P0.6 => MOSI connect to AD7327 DIN
* P0.7 => SSEL connect to AD7327 CS'
*/
#define SSEL (1 << 7)
#define SPI_SPIE (0x00000080)
#define SPI_LSBF (0x00000040)
#define SPI_MSTR (0x00000020)
#define SPI_CPOL (0x00000010)
#define SPI_CPHA (0x00000008)
#define SPI_BitEnable (0x00000004)
#define SPI_Bits (0x00000000)
#define SPI_SPIF (0x00000080)
#define SPI_DIVIDER (8)
/*
* Set up SPI0 as a master with CPOL = 1, CPHA = 0 and 16 bit transfers.
* Force P0.7 to GPIO, set it for output and set it high
*/
void SPI0_init(void)
{
PINSEL0 |= 0x00001500;
PINSEL0 &= ~0x0000C000;
IOSET0 = SSEL;
IODIR0 |= SSEL;
S0SPCR = SPI_MSTR | SPI_CPOL | SPI_BitEnable | SPI_Bits;
S0SPCCR = SPI_DIVIDER;
}
/*
* Send value to ADC and return value shifted in.
*/
unsigned short SPI0_Send(const unsigned short value)
{
IOCLR0 = SSEL;
S0SPDR = value;
while (!(S0SPSR & SPI_SPIF))
;
IOSET0 = SSEL;
return (S0SPDR);
}
You can always just connect MOSI and MISO externally (a jumper wire) and test by looking at what is received versus what it sent. They should be identical.
Richard
Reply by ●August 29, 20112011-08-29
thanks, is it necessary i use interrupts in my code? not only in this case, i am
asking in general. Most of the codes that i have come across for UART,SPI,I2C,
EEPROM, etc., have made use of interrupts.
is it just a better programming technique or is it a necessary one?
--- In l..., "rtstofer" wrote:
>
> --- In l..., "lucky_suhas" wrote:
> >
> > HI again,
> >
> > I have been trying to learn programming using the LPC2148.
> > Thanks to all the people who replied and helped with my ADC code.
> > I am taking the help of some example codes i found online. but with regard to SPI there doesn't seem to be any examples around. although i found one that interfaces SPI to SD card. it was a little difficult to understand. i would like a generalized code on using SPI.
> >
> > i am not asking you to give me the code.. if anyone could suggest me on the various functions that i should write and the process flow. like in ADC i had to write two functions
> > 1.initialization the control register
> > 2.then i had to read the data register.
> For SPI to work, you send a byte or short (8 or 16 bit) out while the hardware simultaneously clocks in a similar data item.
>
> The following code is set up for 16 bit transfers. SPI0_send sends out a 16 bit unsigned short and returns the unsigned short that was clocked in.
>
> #include "lpc214x.h"
> #include "spi.h"
>
> /*
> * P0.4 => SCK connect to AD7327 SCLK
> * P0.5 => MISO connect to AD7327 DOUT
> * P0.6 => MOSI connect to AD7327 DIN
> * P0.7 => SSEL connect to AD7327 CS'
> */
>
> #define SSEL (1 << 7)
> #define SPI_SPIE (0x00000080)
> #define SPI_LSBF (0x00000040)
> #define SPI_MSTR (0x00000020)
> #define SPI_CPOL (0x00000010)
> #define SPI_CPHA (0x00000008)
> #define SPI_BitEnable (0x00000004)
> #define SPI_Bits (0x00000000)
>
> #define SPI_SPIF (0x00000080)
>
> #define SPI_DIVIDER (8)
>
> /*
> * Set up SPI0 as a master with CPOL = 1, CPHA = 0 and 16 bit transfers.
> * Force P0.7 to GPIO, set it for output and set it high
> */
> void SPI0_init(void)
> {
> PINSEL0 |= 0x00001500;
> PINSEL0 &= ~0x0000C000;
> IOSET0 = SSEL;
> IODIR0 |= SSEL;
>
> S0SPCR = SPI_MSTR | SPI_CPOL | SPI_BitEnable | SPI_Bits;
> S0SPCCR = SPI_DIVIDER;
> }
>
> /*
> * Send value to ADC and return value shifted in.
> */
> unsigned short SPI0_Send(const unsigned short value)
> {
> IOCLR0 = SSEL;
> S0SPDR = value;
> while (!(S0SPSR & SPI_SPIF))
> ;
> IOSET0 = SSEL;
> return (S0SPDR);
> }
>
> You can always just connect MOSI and MISO externally (a jumper wire) and test by looking at what is received versus what it sent. They should be identical.
>
> Richard
>
is it just a better programming technique or is it a necessary one?
--- In l..., "rtstofer" wrote:
>
> --- In l..., "lucky_suhas" wrote:
> >
> > HI again,
> >
> > I have been trying to learn programming using the LPC2148.
> > Thanks to all the people who replied and helped with my ADC code.
> > I am taking the help of some example codes i found online. but with regard to SPI there doesn't seem to be any examples around. although i found one that interfaces SPI to SD card. it was a little difficult to understand. i would like a generalized code on using SPI.
> >
> > i am not asking you to give me the code.. if anyone could suggest me on the various functions that i should write and the process flow. like in ADC i had to write two functions
> > 1.initialization the control register
> > 2.then i had to read the data register.
> For SPI to work, you send a byte or short (8 or 16 bit) out while the hardware simultaneously clocks in a similar data item.
>
> The following code is set up for 16 bit transfers. SPI0_send sends out a 16 bit unsigned short and returns the unsigned short that was clocked in.
>
> #include "lpc214x.h"
> #include "spi.h"
>
> /*
> * P0.4 => SCK connect to AD7327 SCLK
> * P0.5 => MISO connect to AD7327 DOUT
> * P0.6 => MOSI connect to AD7327 DIN
> * P0.7 => SSEL connect to AD7327 CS'
> */
>
> #define SSEL (1 << 7)
> #define SPI_SPIE (0x00000080)
> #define SPI_LSBF (0x00000040)
> #define SPI_MSTR (0x00000020)
> #define SPI_CPOL (0x00000010)
> #define SPI_CPHA (0x00000008)
> #define SPI_BitEnable (0x00000004)
> #define SPI_Bits (0x00000000)
>
> #define SPI_SPIF (0x00000080)
>
> #define SPI_DIVIDER (8)
>
> /*
> * Set up SPI0 as a master with CPOL = 1, CPHA = 0 and 16 bit transfers.
> * Force P0.7 to GPIO, set it for output and set it high
> */
> void SPI0_init(void)
> {
> PINSEL0 |= 0x00001500;
> PINSEL0 &= ~0x0000C000;
> IOSET0 = SSEL;
> IODIR0 |= SSEL;
>
> S0SPCR = SPI_MSTR | SPI_CPOL | SPI_BitEnable | SPI_Bits;
> S0SPCCR = SPI_DIVIDER;
> }
>
> /*
> * Send value to ADC and return value shifted in.
> */
> unsigned short SPI0_Send(const unsigned short value)
> {
> IOCLR0 = SSEL;
> S0SPDR = value;
> while (!(S0SPSR & SPI_SPIF))
> ;
> IOSET0 = SSEL;
> return (S0SPDR);
> }
>
> You can always just connect MOSI and MISO externally (a jumper wire) and test by looking at what is received versus what it sent. They should be identical.
>
> Richard
>
Reply by ●August 29, 20112011-08-29
its a bit difficult to follow or maybe its just me. of course once i learn what
i am doing it might just be helpful. thanks!
--- In l..., "rtstofer" wrote:
>
> --- In l..., "lucky_suhas" wrote:
> >
> > HI again,
> >
> > I have been trying to learn programming using the LPC2148.
> > Thanks to all the people who replied and helped with my ADC code.
> > I am taking the help of some example codes i found online. but with regard to SPI there doesn't seem to be any examples around. although i found one that interfaces SPI to SD card. it was a little difficult to understand. i would like a generalized code on using SPI.
> >
> > i am not asking you to give me the code.. if anyone could suggest me on the various functions that i should write and the process flow. like in ADC i had to write two functions
> > 1.initialization the control register
> > 2.then i had to read the data register.
> >
> > i'll give it a try and get back to you for your suggestions.
> >
> > also any suggestions or tips on things to keep an eye out for while using UART.
> > Thanks for reading!
> >
> Everything you could possibly need to know about the LPC2148 is available at www.jcwren.com/arm
>
> Much of the code is wrapped around FreeRTOS (a real-time operating system) but you can easily see how each peripheral is used. JC did a great job with this code.
>
> I use it for reference whenever I begin a project with the LPC2148.
>
> Richard
>
--- In l..., "rtstofer" wrote:
>
> --- In l..., "lucky_suhas" wrote:
> >
> > HI again,
> >
> > I have been trying to learn programming using the LPC2148.
> > Thanks to all the people who replied and helped with my ADC code.
> > I am taking the help of some example codes i found online. but with regard to SPI there doesn't seem to be any examples around. although i found one that interfaces SPI to SD card. it was a little difficult to understand. i would like a generalized code on using SPI.
> >
> > i am not asking you to give me the code.. if anyone could suggest me on the various functions that i should write and the process flow. like in ADC i had to write two functions
> > 1.initialization the control register
> > 2.then i had to read the data register.
> >
> > i'll give it a try and get back to you for your suggestions.
> >
> > also any suggestions or tips on things to keep an eye out for while using UART.
> > Thanks for reading!
> >
> Everything you could possibly need to know about the LPC2148 is available at www.jcwren.com/arm
>
> Much of the code is wrapped around FreeRTOS (a real-time operating system) but you can easily see how each peripheral is used. JC did a great job with this code.
>
> I use it for reference whenever I begin a project with the LPC2148.
>
> Richard
>
Reply by ●August 29, 20112011-08-29
thanks for that link. it helped a lot!
--- In l..., roelof 't Hooft wrote:
>
> On Sun, 2011-08-28 at 14:26 +0000, lucky_suhas wrote:
> > i am not asking you to give me the code.. if anyone could suggest me
> > on the various functions that i should write and the process flow.
>
> Hi,
>
> Almost on the bottom of this page :
> http://www.nxp.com/#/pip/pip=[pip=LPC2141_42_44_46_48]|
> pp=[t=pip,i=LPC2141_42_44_46_48]
>
> you will find this link "LPC2xxx SPI master code example" :
>
> http://www.nxp.com/documents/other/MACC06001_LPC2000_SPI.pdf
>
> There is more what you might want to look at.
>
> roelof
>
--- In l..., roelof 't Hooft wrote:
>
> On Sun, 2011-08-28 at 14:26 +0000, lucky_suhas wrote:
> > i am not asking you to give me the code.. if anyone could suggest me
> > on the various functions that i should write and the process flow.
>
> Hi,
>
> Almost on the bottom of this page :
> http://www.nxp.com/#/pip/pip=[pip=LPC2141_42_44_46_48]|
> pp=[t=pip,i=LPC2141_42_44_46_48]
>
> you will find this link "LPC2xxx SPI master code example" :
>
> http://www.nxp.com/documents/other/MACC06001_LPC2000_SPI.pdf
>
> There is more what you might want to look at.
>
> roelof
>
Reply by ●August 29, 20112011-08-29
--- In l..., "lucky_suhas" wrote:
> thanks, is it necessary i use interrupts in my code? not only in this case, i am asking in general. Most of the codes that i have come across for UART,SPI,I2C, EEPROM, etc., have made use of interrupts.
> is it just a better programming technique or is it a necessary one?
>
No, you don't need to use interrupts. But if you don't, you will spend a lot of compute cycles waiting in loops and not doing other stuff. This may not be important at this point in your learning cycle.
Once you start developing more advanced programs, you will want to use interrupts and I/O buffers. When you get around to using an RTOS (Real Time Operating System), you will have to use interrupts.
Nevertheless, you can write a lot of programs before you have to worry about interrupts.
All that said, your first step into interrupts will probably be serial input. By definition, that input is asynchronous to your program and you can't predict when a character will come along. In many applications your program depends on the next character and it can just wait or, perhaps, check for character availability from time to time. But, sooner or later, you will want the arrival of a character to just notify your program of its arrival.
The next step will probably be character output. You won't want your application waiting around to send a series of chars out the serial port. You will want to stick them in an output buffer and let the serial port interrupt routine handle sending them along.
The programs you see that use interrupts were written for performance. You will get there...
Richard
> thanks, is it necessary i use interrupts in my code? not only in this case, i am asking in general. Most of the codes that i have come across for UART,SPI,I2C, EEPROM, etc., have made use of interrupts.
> is it just a better programming technique or is it a necessary one?
>
No, you don't need to use interrupts. But if you don't, you will spend a lot of compute cycles waiting in loops and not doing other stuff. This may not be important at this point in your learning cycle.
Once you start developing more advanced programs, you will want to use interrupts and I/O buffers. When you get around to using an RTOS (Real Time Operating System), you will have to use interrupts.
Nevertheless, you can write a lot of programs before you have to worry about interrupts.
All that said, your first step into interrupts will probably be serial input. By definition, that input is asynchronous to your program and you can't predict when a character will come along. In many applications your program depends on the next character and it can just wait or, perhaps, check for character availability from time to time. But, sooner or later, you will want the arrival of a character to just notify your program of its arrival.
The next step will probably be character output. You won't want your application waiting around to send a series of chars out the serial port. You will want to stick them in an output buffer and let the serial port interrupt routine handle sending them along.
The programs you see that use interrupts were written for performance. You will get there...
Richard
Reply by ●August 29, 20112011-08-29
so what an interrupt would do is to carryout the ISR in the background while the
rest of the code execution continues?
regarding the ISR address:
i have noticed
1. VICVectAddr=0;
/*is used at the end of the code to reset the VIC in the __irq*/
2. VICVectAddr0= (unsigned int) &name_of_ISR;
/* is used in the initialization of the particular function*/
in point 1. what is the meaning of resetting the VIC? addr register is only to store the ISR address and more over it should have a suffix of 0-15, right?
in point 2. why is it necessary the data type be given? is it possible the compiler might assign a different type to a Lvalue of the function?
--- In l..., "rtstofer" wrote:
>
> --- In l..., "lucky_suhas" wrote:
> >
> >
> > thanks, is it necessary i use interrupts in my code? not only in this case, i am asking in general. Most of the codes that i have come across for UART,SPI,I2C, EEPROM, etc., have made use of interrupts.
> > is it just a better programming technique or is it a necessary one?
> > No, you don't need to use interrupts. But if you don't, you will spend a lot of compute cycles waiting in loops and not doing other stuff. This may not be important at this point in your learning cycle.
>
> Once you start developing more advanced programs, you will want to use interrupts and I/O buffers. When you get around to using an RTOS (Real Time Operating System), you will have to use interrupts.
>
> Nevertheless, you can write a lot of programs before you have to worry about interrupts.
>
> All that said, your first step into interrupts will probably be serial input. By definition, that input is asynchronous to your program and you can't predict when a character will come along. In many applications your program depends on the next character and it can just wait or, perhaps, check for character availability from time to time. But, sooner or later, you will want the arrival of a character to just notify your program of its arrival.
>
> The next step will probably be character output. You won't want your application waiting around to send a series of chars out the serial port. You will want to stick them in an output buffer and let the serial port interrupt routine handle sending them along.
>
> The programs you see that use interrupts were written for performance. You will get there...
>
> Richard
>
regarding the ISR address:
i have noticed
1. VICVectAddr=0;
/*is used at the end of the code to reset the VIC in the __irq*/
2. VICVectAddr0= (unsigned int) &name_of_ISR;
/* is used in the initialization of the particular function*/
in point 1. what is the meaning of resetting the VIC? addr register is only to store the ISR address and more over it should have a suffix of 0-15, right?
in point 2. why is it necessary the data type be given? is it possible the compiler might assign a different type to a Lvalue of the function?
--- In l..., "rtstofer" wrote:
>
> --- In l..., "lucky_suhas" wrote:
> >
> >
> > thanks, is it necessary i use interrupts in my code? not only in this case, i am asking in general. Most of the codes that i have come across for UART,SPI,I2C, EEPROM, etc., have made use of interrupts.
> > is it just a better programming technique or is it a necessary one?
> > No, you don't need to use interrupts. But if you don't, you will spend a lot of compute cycles waiting in loops and not doing other stuff. This may not be important at this point in your learning cycle.
>
> Once you start developing more advanced programs, you will want to use interrupts and I/O buffers. When you get around to using an RTOS (Real Time Operating System), you will have to use interrupts.
>
> Nevertheless, you can write a lot of programs before you have to worry about interrupts.
>
> All that said, your first step into interrupts will probably be serial input. By definition, that input is asynchronous to your program and you can't predict when a character will come along. In many applications your program depends on the next character and it can just wait or, perhaps, check for character availability from time to time. But, sooner or later, you will want the arrival of a character to just notify your program of its arrival.
>
> The next step will probably be character output. You won't want your application waiting around to send a series of chars out the serial port. You will want to stick them in an output buffer and let the serial port interrupt routine handle sending them along.
>
> The programs you see that use interrupts were written for performance. You will get there...
>
> Richard
>
Reply by ●August 29, 20112011-08-29
When an interrupt is triggered the ISR is run. The ISR is not run in the
background, it "pauses" the normal code and runs the ISR. When the ISR returns
the normal code resumes.
--- In l..., "lucky_suhas" wrote:
> so what an interrupt would do is to carryout the ISR in the background while the rest of the code execution continues?
>
> regarding the ISR address:
>
> i have noticed
> 1. VICVectAddr=0;
> /*is used at the end of the code to reset the VIC in the __irq*/
>
> 2. VICVectAddr0= (unsigned int) &name_of_ISR;
> /* is used in the initialization of the particular function*/
>
> in point 1. what is the meaning of resetting the VIC? addr register is only to store the ISR address and more over it should have a suffix of 0-15, right?
>
> in point 2. why is it necessary the data type be given? is it possible the compiler might assign a different type to a Lvalue of the function?
>
> --- In l..., "rtstofer" wrote:
> >
> >
> >
> > --- In l..., "lucky_suhas" wrote:
> > >
> > >
> > > thanks, is it necessary i use interrupts in my code? not only in this case, i am asking in general. Most of the codes that i have come across for UART,SPI,I2C, EEPROM, etc., have made use of interrupts.
> > > is it just a better programming technique or is it a necessary one?
> > >
> >
> > No, you don't need to use interrupts. But if you don't, you will spend a lot of compute cycles waiting in loops and not doing other stuff. This may not be important at this point in your learning cycle.
> >
> > Once you start developing more advanced programs, you will want to use interrupts and I/O buffers. When you get around to using an RTOS (Real Time Operating System), you will have to use interrupts.
> >
> > Nevertheless, you can write a lot of programs before you have to worry about interrupts.
> >
> > All that said, your first step into interrupts will probably be serial input. By definition, that input is asynchronous to your program and you can't predict when a character will come along. In many applications your program depends on the next character and it can just wait or, perhaps, check for character availability from time to time. But, sooner or later, you will want the arrival of a character to just notify your program of its arrival.
> >
> > The next step will probably be character output. You won't want your application waiting around to send a series of chars out the serial port. You will want to stick them in an output buffer and let the serial port interrupt routine handle sending them along.
> >
> > The programs you see that use interrupts were written for performance. You will get there...
> >
> > Richard
>
--- In l..., "lucky_suhas" wrote:
> so what an interrupt would do is to carryout the ISR in the background while the rest of the code execution continues?
>
> regarding the ISR address:
>
> i have noticed
> 1. VICVectAddr=0;
> /*is used at the end of the code to reset the VIC in the __irq*/
>
> 2. VICVectAddr0= (unsigned int) &name_of_ISR;
> /* is used in the initialization of the particular function*/
>
> in point 1. what is the meaning of resetting the VIC? addr register is only to store the ISR address and more over it should have a suffix of 0-15, right?
>
> in point 2. why is it necessary the data type be given? is it possible the compiler might assign a different type to a Lvalue of the function?
>
> --- In l..., "rtstofer" wrote:
> >
> >
> >
> > --- In l..., "lucky_suhas" wrote:
> > >
> > >
> > > thanks, is it necessary i use interrupts in my code? not only in this case, i am asking in general. Most of the codes that i have come across for UART,SPI,I2C, EEPROM, etc., have made use of interrupts.
> > > is it just a better programming technique or is it a necessary one?
> > >
> >
> > No, you don't need to use interrupts. But if you don't, you will spend a lot of compute cycles waiting in loops and not doing other stuff. This may not be important at this point in your learning cycle.
> >
> > Once you start developing more advanced programs, you will want to use interrupts and I/O buffers. When you get around to using an RTOS (Real Time Operating System), you will have to use interrupts.
> >
> > Nevertheless, you can write a lot of programs before you have to worry about interrupts.
> >
> > All that said, your first step into interrupts will probably be serial input. By definition, that input is asynchronous to your program and you can't predict when a character will come along. In many applications your program depends on the next character and it can just wait or, perhaps, check for character availability from time to time. But, sooner or later, you will want the arrival of a character to just notify your program of its arrival.
> >
> > The next step will probably be character output. You won't want your application waiting around to send a series of chars out the serial port. You will want to stick them in an output buffer and let the serial port interrupt routine handle sending them along.
> >
> > The programs you see that use interrupts were written for performance. You will get there...
> >
> > Richard
>