Please help: Simple program using interrupt on LPC12xx

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please help: Simple program using interrupt on LPC12xx

577 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tbutuza on Thu May 12 11:01:04 MST 2011
Hello,

I try to learn programming LPC1227.
Previously I could make simple programs for LPC1769 but I have almost no success with LPC1227.

I'd like to use interrupt for some simple tasks for example blinking a led by Systick or catch received characters from uart0 by interrupt.
When I do led blinking with loops, it works. So the compiler, downloader and my hardware seems ok. But when trying use interrupt, I have no success.
Unfortunately I did not found useful tutorial or good example programs for LPC12 on the Internet. Or, when I found something it is really hard to make it complete with libraries, makefile and linker script.

Please help me. I'd like to have a simple program that demonstrates using interrupt on LPC12 without any extra libraries.
I'd like to have a really easy to understand, simple (without extra libraries, CMSIS) but complete (all necessary headers, linker script, makefile) reproducible project.
The  rpgram should be compiled without using ide, just by command line gnu tools.

I'm using gnu compiler on Ubuntu 11.04 and using lpc21isp for programming the chip using its built-in bootloader.
I've patched the lpc21isp to program LPC1227, because originally it does not support it.

I use a custom board for LPC1227. It has nothing special.
The only significant features are the power regulator, quartz and a led tied to one pin (interfaced by a transistor)

Best regards,
Tamas Butuza
0 Kudos
13 Replies

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Fri May 13 20:35:38 MST 2011
Tamas,

Congratulations on getting the blinky working.

Larry
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tbutuza on Fri May 13 17:46:58 MST 2011
Hello,

Now my simple systick-interrupt blinky program runs on LPC1227!
It is based on on example from the Blinky thread. I could successfully port it to LPC12 and rip off completelly the cmsis.
The key of the success is: Disable the watchdog at the beginning of the code.
It was not needed on my previous project on LPC1769.

My next step: Using UART.
To talking about using uart on LPC12xx, I started a new thread:
http://knowledgebase.nxp.com/showthread.php?t=1914
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Fri May 13 11:22:43 MST 2011

Quote: akhilpo
If I exclude CMSIS, what other things will I have to take care?



Build a simple working program using the IDE to properly set up the C run time environment, and use CMSIS to access the peripherals in a convenient fashion.

Study the cr_startup code, peruse the source and header files of the CMSIS library. Fully understand what they do.  Then you can decide whether to 'roll your own' startup and do without CMSIS.

I see that you have posted in the Minimal Blinky thread. That was an exercise in trying to do without the cr_startup and libraries. But as you have found out, you cannot just drop those examples in to a different device and expect it to run without completely understanding how they work.
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by akhilpo on Fri May 13 00:25:44 MST 2011

Quote: jharwood
CMSIS is great for multi-platform unity, code portability, maintainability ...etc.

If your system is memory constrained however, try building a project with and without CMSIS and check the differences in code size.



If I exclude CMSIS, what other things will I have to take care?
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Thu May 12 23:59:38 MST 2011

Quote: fastmapper
For the LPC1227, the boot ROM enables the watchdog timer after reset.  Have you disabled it or ensured that it gets fed.



I don't think they have gotten to that point yet, but thanks for the heads up.
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fastmapper on Thu May 12 23:16:03 MST 2011
For the LPC1227, the boot ROM enables the watchdog timer after reset.  Have you disabled it or ensured that it gets fed.
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Thu May 12 22:41:52 MST 2011

Quote: akhilpo
Whats the point in going below that layer?



CMSIS is great for multi-platform unity, code portability, maintainability ...etc.

If your system is memory constrained however, try building a project with and without CMSIS and check the differences in code size.
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by akhilpo on Thu May 12 21:31:04 MST 2011
isn't CMSIS just maps and gives each peripherals a standard name? Whats the point in going below that layer?
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Thu May 12 16:25:39 MST 2011

Quote: tbutuza
I tried it, but failed.
Compilig done without error but the resulting hex file is surprisingly small, only 79 bytes. It is certainly wrong.



Tamas,

Post your code here on the forum and we can take a look at it to try to help you get started.

Using command line tools is ok if you want to use them.  We can help you with using the command line debugger (gdb) as well.

I think CodeRedSupport can better answer your concerns and questions about the IDE and CMSIS.

Larry
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tbutuza on Thu May 12 14:32:46 MST 2011
Hello Larryvc.

I prefer use simple command line tools for learning instead of ide because I'd like to understand the basics :-) Using IDE hides a lot of interesting and important things. For example, using LPCXpresso ide, I cannot learn how does the linker script and makefile work.
I feel this LPCXpresso systick example is too complicated. A simple led blinking program consists of a lot of source files, needs cmsis... Why?

I really prefer simple (if possible single file) example programs for demonstrating basic functions of the mcu. Such a small simple example let me easily understand the basics. It is the reason why I'm sad with lpcxpresso examples.

I feel these examples are designed to live inside lpcxpresso environment. It seems too hard to separate them and try compile them outside of lpcxpresso.

I tried it, but failed.
Compilig done without error but the resulting hex file is surprisingly small, only 79 bytes. It is certainly wrong.

Tamas
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Thu May 12 13:45:08 MST 2011

Quote: tbutuza

My problem is that it is not clear to me how to do such interrupt stuff on LPC12xx.
I tried to port LPC1768 systick led blinker program to LPC1227 but it does not work.



My first question is, why aren't you using the LPCXpresso IDE?  At least use it to get an understanding of basics and then you can go off in your own direction.

You should probably try using the LPCXpresso examples in the LPCXpresso IDE version 3.8.3 for linux.

You will find the LPCXpresso1227_systick example project and some others in the IDE.

Do you realize that the LPC1227 is a Cortex M0 and the LPC1769 is a Cortex M3?
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tbutuza on Thu May 12 12:57:38 MST 2011
Hello Akhilpo,

Thank you for your help, but the problem is different.

As I wrote I know how to write programs for LPC1768 using interrupts.
So it is clear to me how to deal with irq handlers in general.

My problem is that it is not clear to me how to do such interrupt stuff on LPC12xx.
I tried to port LPC1768 systick led blinker program to LPC1227 but it does not work.
0 Kudos

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by akhilpo on Thu May 12 12:30:58 MST 2011
I am too new to arm. So far i got a enough know how about the working of its perpherals, its mappings etc. But still I dont know how we are implementing interrupts. What I know is there are some handler names defined in 'cr_startup_lpc11.c'. Pick the one required and just declare function with that name. For eg: if you need to implement interrupt for timer0, just declare like this:
void TIMER32_0_IRQHandler (void){
         --Your code--
}

And also include this code in the main function: NVIC_EnableIRQ(IRQ_Type IRQn).

Thats all I know so far. I would like to know much deeper about this if I someone could help.
0 Kudos