PDA

View Full Version : Tini2131 and Keil K_examples


fbowers
02-08-07, 09:59 AM
I tried compiling Keil examples from New Micros website k_examples\adc with uvision3 I downloaded from Keil. It will not compile. Keil tells me the examples will not work with the Realview tool chain. Is there any way to fix this?

nmitech
02-08-07, 10:25 AM
All the examples provided on NMI website are compiled and tested with uvision3 .

fbowers
02-08-07, 03:42 PM
Build target 'LPC 21xx'
assembling Startup.s...
--- Error: can't execute 'C:\Keil\ARM\BIN\AA'
Target not created

this imessage is what I get when I try to compile after extracting k_examples\ADC.

the stdio.h file has a red X on it.

Keil thinks its an old version of code, which does not compile with their newer evaluation software.

I am new to this type of programming, I program in information systems, pls have patience with my learning curve.

mckenney
02-08-07, 09:46 PM
Keil thinks its an old version of code, which does not compile with their newer evaluation software.
As stated, this is a bit odd, since based on the error message you can't compile
anything since uV can't find the compiler (assembler, really) AA.exe. If anything,
I would suspect a version conflict with the project file (ADC.uv2).

I didn't see this particular failure with uV v3.33 (mdk303a), so I upgraded to
v3.50 (mdk304) and I still don't see it. (I did see a different failure, having
to do with the "BROWSE" option, which is easily remedied.)

What version are you running?

Also, what (.EXE files) do you have in C:\Keil\ARM\BIN?

fbowers
02-09-07, 07:58 AM
mckenney thanks for the response!

I am running
uvision version 3.50 evaluation software
and
fcarm.exe is in the bin directory

nmitech
02-09-07, 01:43 PM
fbowers is right. The provided example programs are not 100% compatible with the latest Kiel Eval software, uVision3 V3.50. For a quick workaround, you need to replace the STARTUP.S file with the new STARTUP.S provided in the directory below,
\Keil\ARM\RV30\Startup\Philips\Startup.S
or download from this link,
http://www.newmicros.com/temp/Keil/Startup.s

Next, on the Menu click on PROJECT --> MANAGE -->COMPONETS, ENV..,BOOKS and click on the Folders/Extensions Tab and select the development tools as shown in the image link below,
http://www.newmicros.com/temp/Keil/Folders.gif

On the Menu, FLASH --> CONFIGURE FLASH TOOLS...
Select DEVICE, LPC2131 under Vendor NXP
http://www.newmicros.com/temp/Keil/Device.gif
TARGET, http://www.newmicros.com/temp/Keil/Target.gif
OUTPUT, http://www.newmicros.com/temp/Keil/Output.gif
LINKER, http://www.newmicros.com/temp/Keil/Linker.gif

Now you can Click on the PROJECT --> REBUILD ALL TARGET FILES
to generate the HEX file

fbowers
02-09-07, 04:21 PM
That seems to work!

thank you

fbowers
02-12-07, 09:02 AM
Hi,

The changes to the compiler, as outlined by NmiTech, creates the compile code without error.
However after the new hex file is uploaded with Flash, the ADC no longer works.

Any ideas?

mckenney
02-12-07, 07:36 PM
What is it that isn't working? How are you testing this?

fbowers
02-13-07, 08:14 AM
I have a Tiniarm I am using to convert AC voltages to a Digital signal to the serial port of my PC. I then can read the voltages with a VB program using MSCOMM. The Tiniarm was programed with the Keil K_Examples using the ADC sample code. It was working fine until I recompiled the source with the new compiler. Now I am not getting any through put to the serial port. I have not changed the source, I just tested if the code compiled and still worked as it did before.

Is the new Start file the same for all the examples in k_examples, or is that specific to a specific example like "Hello", "Blinkey", ADC etc?

nmitech
02-13-07, 10:18 AM
For your convinience, the examples are now updated to work with uVision3 V3.50. Here is the direct link,
http://www.newmicros.com/download/appnotes/ARM/K_examples.zip

fbowers
02-13-07, 01:10 PM
nmitech,

Thank you for your help!

I am now however totally lost. What I was trying to do is upgrade a tiniarm, which took an input on ADO.7 and sent that ADC to the serial port of my pc. Then modify it, to in addition accept another input voltage on ADO.5 and output that voltage as well. With the help of Dave Peterson of NMI we, really he, identified the addional bit to turn on as PINSEL1= 0x00100000.

But now I really do not see how to do this.

The new code you provided is different, no doubt better, than what was there before.

Can anyone help me accomplish this?

Thanks to all

Dave
02-13-07, 03:53 PM
Page 193 of the LPC213x User Manual (http://www.semiconductors.philips.com/acrobat_download/usermanuals/UM10120_1.pdf) begins the description the ADCs.

The ADC.c example in the zip file begins showing that PINSEL0 is used to enable AIN0.7 of the ADC0.

PINSEL0 = 0x00000C05; /* Enable RxD0, TxD0 , AIN0.7 */

To this it would seem that you would need a line like

PINSEL1 = 0x00100000; /* Enable AIN0.5 */

As we had seen before.

Then there is a setup of that pin using the ADCR which is the A/D Control Register. It looks like this can set up all ADC pins, from the info on page 194. In the example :

AD0CR = 0x00210680; /* Setup A/D: 10-bit AIN0.7 @ 3MHz */

which is :
0000 0000 0010 0001 0000 0110 1000 0000

expanded to binary. Table 163 shows bits 7 to 0 select the AD0 pins used, so changing these bits to 1010 0000 should set up AIN0.5 for conversion as well. Looks like all other bits remain (for use according to the ADC.c example). Note that 2 pins can be set only when in SCAN or BURST mode, bit 16 set.
So AD0CR would need to be :

AD0CR = 0x002106A0; /* Setup A/D 10-bit AIN0.7 AIN0.5 @ 3MHz */

The next place the ADC appears to be used in actually reading it in the while loop. Here is :

AD0CR |= 0x01000000; /* Start A/D Conversion */

which does not appear to change for reading an extra pin. It looks like an OR to the register to begin conversion.

The result appears on bits 15 to 6 of the AD0DR. In the example there appears to have bits 6 on up mask ANDed with 0x03FF, which is the highest reading possible from the ADC. I'm not sure, but would guess that instead of this, another variable would need to be used to get the results for the AIN0.5 pin. This is assuming that you are wanting results from both AIN0.7 as in the example, and added results from AIN0.5 I'm guessing that bits 26 to 24 need to be checked in reading the AD0DR to see which channel (AIN0.5 or AIN0.7) is being shown when reading this register. Perhaps an additional reading of the AD0DR register will get the "other" pin result, then a similar mask can get the result to be placed in a new variable like val2.

So at the top it might be useful to add :

unsigned int val2;

after the val definition, to accept another ADC reading.
After the first reading of val, perhaps adding :

val2 = ((AD0DR >> 6) & 0x03FF); /*Extract another A/D result */

and repeating the printf functions with val2 being addressed to display that resilt might be useful.

Please note that I have not used to Keil compiler before or this LPC2138 in this way, so this is primarily guesswork, and probably not recommended programming practice. The best thing is to try a few things, see what works. You are not likely to break the part with software.

Oh, one thing noticed in your post, please note a difference between ADO.5 (A D Oh .5, not referencing anything) and AD0.5 ( A D zero.5, addressing the pin/channel) Hopefully someone more conversant in the Keil package could comment on a good practice in reading several ADC results.

* edit: PINSEL0 bits 3,2,1,0 enable TXD0 and RXD0, not TXD1 and RXD1, example corrected too

mckenney
02-13-07, 10:09 PM
AD0CR |= 0x01000000; /* Start A/D Conversion */
It's probably inappropriate to set the START bit in BURST mode. I don't know
why the original was written that way; maybe it accidentally works with only
one channel?
After the first reading of val, perhaps adding :
Don't forget to wait for DONE (AD0DR & 0x80000000) to go high again before
fetching the second value.
bits 26 to 24 need to be checked in reading the AD0DR to see which channel (AIN0.5 or AIN0.7) is being shown
Yes, keep in mind that the ADC will have done 2000-some conversions while
printf() was running, so there's no telling which result will be the next to pop
out.

mckenney
02-14-07, 07:34 PM
Oh, and be sure to download the new .zip file nmitech mentions. You won't
succeed without the Retarget.c stuff.