Showing posts with label LPCXPRESSO. Show all posts
Showing posts with label LPCXPRESSO. Show all posts

Monday, 27 January 2014

Program the flash memory on NXP LPC1769 (put a program on the LCP1769)

 INTRODUCTION

Using the Program Flash feature of LPCXpresso is the easiest way to get a program on an LPC1769 board, it does not require you to flash the board using a command line, it does not requires you to build that program in the IDE, it does not necessitate to start a debug sessing, with this method you can flash on a board a program that was written in an earlier version of the IDE without going through the assle of updating someone else code.
LPC1769 Board from Embedded Artists

 Some terminology used in this arcticle

  •  EA = E.mbedded A.rtists (this is the company that produce the board shown above, other versions are avaiblable too but this one is quite versatile and not too costly)
  •  NXP = NXP semiconductors, a company associated with Phillips that makes Microcontrollers
  •  IC = I.ntegrated C.ircuit ( this is a Silicon Chip that does a specific work, it might be a lot of things)
  • ADC = A.nalog D.igital C.onverter ( this is an device that reads analog voltages and convert it to digital data usable in processors)
  • PWM = P.ulse W.idth M.odulator (this device generate a frequency which On and OFF time vary)
  • IDE = I.ntegrated D.eveloppment E.nvironement (this is an application used to construct other applications)
  • MCU = Microcontroller (this is an IC that contains a processor, some RAM, some built in peripherals like ADC ,PWM ,Timers, Digital Inputs and Output), like an old computer with low power ,used to do tasks that require real time precision)
  • UI = U.ser I.nterface ( this is buttons, dialogs, windows, textboxes, pictures that compose an application)

What will you learn today

The aim of this article is to learn how to put a program on the LPC1769 board from EA with the use of a PC, USB cable and the Program Flash feature in LPCXpresso IDE.

REQUIERMENTS

This is all you need + PC, cleverness and patience!

 

  • PC with powerfull USB ports,(What??, yeah ... the EA boards require a USB port with good power to be able to flash the memory without errors. Avoid laptops if possible since they generally have weaker USB ports) 
  • PC with Windows XP SP3 or above, Windows 7 64b was used for the writing of this guide
  • USB cable with a Mini-B end
USB with Mini-B end 



 GETTING THE IDE TO WORK

The current version used for this guide is 6.1.4 using the default installation application UI layout

Get the Windows installer on NXP LPCXpresso download section 
Install the IDE following default choices, install the drivers when asked to.
Do not start the IDE at the completition of the installation.
Connect the LPC1769 board to USB cable to PC.
Let the computer install automatically the drivers for the device.
After this is done you can now start LPCXpresso

STARTING/SETUPING THE IDE FOR THE FIRST TIME

Check  'use this as the default and do not ask again', this will be simpler every time you start this application.

Application mandatory registration

Not registered warning
At first startup, the application will complain that it is not registered. To be able to program the LPC1769 flash memory we need to register .Please follow the steps below to do so, it should take you 5-10m playing in a web browser and copy/paste text data. It's boring, but in the end programming flash memory is a lot easier than not registering and building yourself the application and starting a debug session to get the program on the MCU ;)



1- You need to create a free user account on www.lpcware.com here

 2- once you have a working account, you can register an intstalled copy of LPCXpresso

Here are the steps to register in pictures, quite easy

get a serial number and start registration process
Get Activation key from lpcware.com using your user account and the serial number.
After this you have a registered free version of the IDE and you can use the Program Flash feature that was disabled before registration.

USING THE IDE TO INSTALL PROGRAM ON LPC1769


First you need a project built specifically for you target Board, in today's case this is a LPC1769 project.

You need to import your project in the IDE by using the following actions 

File/Import ...
Choose General/existing projects
Choose 'Select archive file' then find your ZIP file, check everything from your archive file then finish


Now that the project is imported in the Workspace you can install the  existing *.afx file on the LPC1769

Select your project in the Project Explorer
Then press on the Silicon Chip Icon , this is the Program Flash feature


LPCXpresso will initialize the LPC1769 board driver then display the Program Flash Dialog that will allow you at last to program the Board, the target board was detected by LPCXpresso and do not need to be changed

After you hit OK a progress dialog should appear and tell you if it succeeded or not. In case it did not succeed, think about using another USB port or even another computer, remember to avoid laptops for this task.
You have now finished with the IDE and therefore can close it

CONCLUSION

You now have a program on your LPC1769, everytime the board will be powered the program there will automatically start.

Monday, 30 December 2013

Random color Led Stripe for the Car!

What is the reason for this?

Earlier this year I had a plain idea, and then I decided to make it more fun. What if I had an RGB led stripe to make some nice ambiance in my car...no... not strikink enough... Wait, why not make it change color every time I press the clutch. That would be something quite unique, random colors changes makes for an imaginative environement! So I let this idea aside for some months and as winter came so did the interest to make it come to life.

What it looks installed in the car
Here is a poor video showing the device in action

Theory of operation (RGB LEDS and pulsewidth modulation)

For those not familliar with RGB led stripes, it is quite simple there is 3 leds X some distance(ex 2m), Red, Green, Blue. by adusting the voltage fed to each of those 3 channels we can produce a chosen color. To do this my device emits a constant frequency, what makes the color is that the pulse widht vary according to each channels. This in turn power each channel to a certain level and can produce a color predicted in the  software.
My christmass tree for 2013


Comparison of 2 colors being produced by the same device

How it is done Hardware side

LPC1115 ,the led Drivers on the prototyping area of the LPC board, and the 5v power supply

I currently use NXP LPCXPRESSO boards for my MCU projects so it had to use one.
The LPC1115 was chosen because:
1) it comes with it's own programmer/debuger attached,
2) it's price as a dev board is not too high IMO.
3) it's processing power and built-in features is also interesting in other projects, reusability was in mind.
4) C programming Language, personal preferences I guess....
5) The eclipse Based IDE is easy to get along if you already know eclipse for other programming tasks.
6) Building and installation of software on this board can be done by people with little electronics or programming knowledge.(might make a tutorial on this at sometime)

LED stripe would be a 3 channels 12v 2meters unit. 
3 x TIP122 as switching transistors would be used to control how long each Color would be powered. 
Appropriate resitors would be used between the LPC1115 and the TIP122, this is necessary to make the transistor work as a switching transistor. 10k ohms was the value that worked for my LEDs stripe. with varying lenght of LED stripe and power consumption the resistor values should vary...
 An instantaneous switch would be used to trigger the color change. this switch would have to be debounced with a pull-down resistor so that it does not trigger unexpectedly(*it might not even suffice if the switch used is really crappy)
A 2.2k ohms resistor was used to do the pull-down work on the switch.
A USB adapter for the car that connect in the cigarette lighter was dismantled and used as a "clean" 5v dc power source coming from a 12v dc environement (this device is made to work in a car, remember;) )
A plastic case and a 9 pin connector was used to protect and make installation/removal easier

*the JTAG debugger is the left half of the LPC1115 PCB, it can be cut out, by doing this one person cannot power it's LPC1115 from the JTAG debugger usb connector, it cannot reprogram the device unless it is connected again.

this JTAG debugger does takes room in this particular project, but with possible reusability in mind and further features addition I decided to keep the JTAG debugger in place and live with the extra room necessary for it.

Power does not come from A USB cable connected to JTAG and to a 12V->USB adapter, for this project I choosed to power the LPC1115 directly on the board (yellow and green wire coming from the lower PCB in the picture)  when programming the device turn off power from this source

LEDs driver shematics

  
4 pins on the LPC1115 are used, 
Red channel is controled by Port 0 pin 7
Green channel is controled by Port 1 pin 8
Blue channel is controled by Port 0 pin 6
Button input comes from Port 0 pin 10

How it is done Software side

the software that controls the Transistors was written with the  LPCXpresso v5.1.2 IDE.
it is a C program that choose at random a color when it starts. then enter an infinite loop where it checks if the button was pressed and generate another random color that will be used.
two 32b timers are used together to produce a frequency not visible to the eye and the pulse width control.

Things to learn from this C program

-Analog Input readings
-Random numbers generation on a Microcontroller with no feature built-in ( Uses floating ADC pins for initialization)
-Working with 32b timers
-Working with GPIO input and output

this program CAN be improved.A better design using more built-in features of the LPC1115 could be made to control the frequency and pulsewidth.

Download the project files


Any feedback is welcome.