1.
Does the SCARM C Compiler support XYZ micro-controller?
2.
I compiled my program, there are no errors, but .HEX file is not
produced. Why?
3.
What is a ‘project’? How can I create a new ‘project’?
4.
How do I write an application program for LPC2138 / LPC2104 /
LPC2148 / LPC2378 / STR711 / STR712 ?
5.
How do I program the LPC2138 / LPC2104 / LPC2148 ?
6.
How do I program the LPC2378 ?
7.
How do I program the STR711 / STR712 ?
8.
How do I test my program using MiniARM?
Click on the question to see answer.
If you have another question (not listed here), you
may please write to: spj@spjsystems.com
Q1. Does the SCARM C
Compiler support XYZ micro-controller?
Answer: SCARM C Compiler currently supports all ARM7TDMI
family micro-controllers, and future versions may also support other ARM
architecture variants. The Project/Settings in the IDE ask you to select a
manufacturer (like Philips, Atmel...) and then further to select the device
(like LPC2138...). We try to keep this list updated, however some of the ARM
micro-controllers may not be mentioned in the list. It does NOT mean that
it is not supported. If the device you wish to use is not displayed in
the list, you may select "Generic" as manufacturer and “Generic” as
the device. In the “Linker settings” (under Project/Settings dialog), you may
change the start addresses and sizes of ROM and/or RAM, if necessary. The
Special Function Registers of your ARM micro-controller maybe defined manually,
by using the form:
#define SFR_NAME (*((volatile WORD32 *) 0xE0000000))
where “SFR_NAME” should be replaced by the actual
name of that Special Function Register; the “0xE0000000” above indicates the
address of the memory mapped SFR – it should be replaced by whatever is the
actual address. This way you may declare all the SFRs.
Q2. I compiled my program,
there are no errors, but .HEX file is not produced. Why?
Answer: Selecting Compile from Compile menu
will simply compile the currently active source file. To get the HEX code, you
need to select Build or Re-build all from Compile menu.
Number of things happen when you do so:
·
First
C file of this project is compiled. The result of compiling is that the Object
module or .OBJ file is produced (if there are no errors).
·
The
same process is repeated for all other C files of this project.
·
First
ASM file of this project is assembled. The result of assembling is that the
Object module or .OBJ file is produced (if there are no errors).
·
The
same process is repeated for all other ASM files of this project.
·
The
Linker is invoked with all the OBJ files produced in the above steps as well
all OBJ files that are part of this project. If there are no errors, the .HEX
file is produced. It has the same name as the project filename, but the
extention is .HEX.
·
If
there is even a single error in any of the above steps, then the .HEX will not
be produced.
Upon selecting Re-build all, attempt is made
to compile or assembly all source files; if no errors, then linking is
performed.
Upon selecting Build only those steps are
performed that are necessary. In this case, the IDE will check dependencies
based on file date and time stamp. For example: if MODULE1.OBJ file is newer
than MODULE1.C, then it means that the file MODULE1.C has been compiled already
and the .OBJ file is ready. Hence, MODULE1.C file will not be compiled again.
Similar check will be performed for all other parts of the project.
Sometimes the IDE may not be able to detect
dependencies due to number of reasons. If you suspect so, then please select Re-build
all to create the .HEX file.
Q3. What is a ‘project’? How
can I create a new ‘project’?
Answer: A ‘project’ maybe considered as a collection of
modules. All these modules together make up the application. In some cases, a
project may have only a single module. Theoretically, a project can have any
number of modules; for practical reasons, the IDE allows upto 48 modules in a
project.
A ‘module’ can be one of the 4:
·
C
source program file (generally filename extention .C)
·
Assembly
language source program file (generally filename extention .ASM)
·
Object
module (generally filename extention .OBJ)
·
Library
(generally filename extention .LIB)
Any C project (that is- a project which has at least
one C source program module) must also have the module “startup.asm”. This
module is automatically created by the compiler and it is not expected to be
modified by the user.
Follow these steps to create a new C project:
·
Start
the IDE of SCARM C Compiler for ARM.
·
Select
“Close project” from “Project” menu.
·
Select
“Close file” from “File” menu; repeat it until all files are closed.
·
Select
“New project” from “Project” menu.
·
Select
the desired path where you would like to create the project.
·
Type
appropriate filename for the project. Please do not type any filename
extention. For example, you may type MyFirst.
·
Press
“Open” button.
·
The
Project Settings window will pop-up.
·
If
you know the target micro-controller of your application: select manufacturer
from he list and then select the desired target from the list of
micro-controllers. Otherwise, select Generic/Generic.
·
Click
on the “Source files” tab within the Project settings window.
·
You
will notice that the IDE has automatically added two files in your project: startup.asm
and MyFirst.C. In fact, if MyFirst.C does not exist, then the IDE will
actually create it.
·
If
you wish to add any other modules to the project, you may do so by pressing Add
file button.
·
Finally,
press OK button to create the project.
Q4. How do I write an
application program for LPC2138 / LPC2104 / LPC2148 / LPC2378 / STR711 / STR712?
Answer: Using SCARM C Compiler for ARM,
it is quite straightforward. Please refer to answer of question: What
is a ‘project’? How can I create a new ‘project’? While creating new
project, select appropriate manufacturer (Philips or ST) and micro-controller
from the list. When the new project has been created, an empty C program file
will be also automatically created and opened in the Editor. You may write your
program here. When finished writing, simply select Build option from Compile
menu. Look into messages in the Output window (below the Editor window).
If there are errors, you may double-click on it to goto the line that caused
error. When there are no errors, you should see the message “.HEX file created
successfully!” in the Output window. That means, you have successfully written
an application for your ARM micro-controller.
Q5. How do I program the
LPC2138 / LPC2104 / LPC2148?
Answer: This question is answered in context of
MiniARM evaluation boards. I.e. it is assumed that you have the MiniARM-2138 or
MiniARM-2104 or MiniARM-2148 board with you.
If you have MiniARM-2104 board: there is a big
blue/white push-button on the board. Press it once. It should stay down. Now
the board is in PROGRAM mode.
If you have MiniARM-2138 or MiniARM-2148 board: This
board has a toggle switch for selecting between PROGRAM mode and RUN mode. Toggle
that switch into PROGRAM mode position (i.e. downwards or away from the red
LED).
Then run appropriate version of LPC2000 ISP
software. The CD you received with MiniARM board contains evaluation version of
SCARM C Compiler for ARM. When you install it, you will see the folder
SCARM\Utilities. This folder contains various versions of ISP flash utility for
LPC2000 family micro-controllers. NOTE: This ISP flash utility is not an SPJ
product. These have been downloaded from Philips Semiconductor (NXP) web
site. You may install appropriate version of this ISP flash utility. Alternatively,
you may visit Philips web
site to see if they have another version.
To install the ISP software, you may extract the
appropriate zip file and then run SETUP.EXE from the extracted files. Some
computers may need to be restarted after installing the software; although the
setup program may not necessarily prompt you to restart computer. It is best to
restart the computer anyway.
After that, follow these steps for programming the
flash:
1.
Run
the ISP software.
2.
From
the device list, select appropriate device (LPC2138 or LPC2104 or LPC2148).
3.
Enter
crystal frequency correctly (14746 for MiniARM-2138 or 11059 for
MiniARM-2104 or 12000 for MiniARM-2148).
4.
Keep
the MiniARM board power switched off. Set the board to PROGRAM mode, as
described above. Connect board to PC COM port with supplied serial cable.
Please do not use any other serial cable.
5.
In
ISP software, select appropriate COM port.
6.
Click
on "Read Device ID" button. Switch on power to the board only after
you see the message "Please reset your LPC2000 board now and then press
ok!". Wait for a second or two, and then click OK button.
7.
If
all is well, you will see the "Part ID" and "Boot Loader
ID" displayed.
8.
Click
on the "browse" button (actually it is only marked as
"..."). Select appropriate HEX file. You may use one of the example
programs included in the SCARM software. MiniARM examples can be found under
the folder SCARM\Examples\MiniARM. There are sub-folders for each model of
MiniARM boards.
9.
Click
on "Upload to flash" button.
10. Uploading progress will be
displayed. When done, close the ISP program and switch off power to the board.
Q6. How do I program the
LPC2378?
Answer: This question is answered in context of
MiniARM evaluation boards. I.e. it is assumed that you have the MiniARM-2378 board
with you.
There are 2 ways to put the LPC2378 in PROGRAM mode:
You may do it manually, by placing a jumper. Alternatively, you may set the
jumpers in such a way that the ISP software running on PC will automatically
put the LPC2378 in PROGRAM or RUN mode. Choose whichever method appropriate for
you. For details of jumper setting, please refer to users manual of
MiniARM-2378.
Then run FlashMagic (Version 3.42.179 or above). The
CD you received with MiniARM board contains evaluation version of SCARM C
Compiler for ARM. When you install it, you will see the folder SCARM\Utilities.
This folder contains FlashMagic3.42.zip. NOTE: FlashMagic is not an SPJ
product. It has been downloaded from FlashMagic web site.
To install the ISP software, you may extract the zip
file and then run FlashMagic.exe.
After that, follow these steps for programming the
flash:
1.
Run
FlashMagic.
2.
From
the device list, select appropriate device (LPC2378).
3.
Enter
crystal frequency correctly (12.0 MHz).
4.
Keep
the MiniARM board power switched off. Use appropriate jumper setting. Connect
board to PC COM port with supplied serial cable. Please do not use any other
serial cable.
5.
Ensure
all other FlashMagic settings are appropriate. Then click on the START button.
6.
Switch
on power to the board.
7.
If
all is well, you will see erasing / programming progress until the operation
completes.
8.
When
done, you may close FlashMagic program and switch off power to the board.
9.
If
you used manual jumper setting to put the board in PROGRAM mode, you need to
change the jumper setting to bring the board back in RUN mode. Then turn ON
power and your program should run.
Q7. How do I program the STR711
/ STR712?
Answer: This question is answered in context of
MiniARM evaluation boards. I.e. it is assumed that you have the MiniARM-STR711
or MiniARM-STR712 board with you.
You also need a JTAG cable
(either SJT-S or SJT-U) and the SDB debugger. The SDB
debugger is included in the evaluation version of SCARM. JTAG Cable needs to be purchased separately.
Connect the MiniARM board to computer with the JTAG
cable. Then run SDB debugger software. Turn ON power to the board.
After that, follow these steps for programming the
flash:
1.
From
the Run menu, select “Not connected to Target. Click here to connect”.
2.
The
debugger should display ID code of the ARM micro-controller. It should be
displayed as 0x3F0F0F0F.
3.
From
the Run menu, select “Stop”. This will halt the STR711 or STR712
micro-controller.
4.
From
the Tools menu, select “Flash Programming”. The Flash programming dialog will
be displayed.
5.
Select
the processor, as appropriate (STR711 or STR712)
6.
Click
on the “Browse” button and select appropriate .HEX file. When you do so, some
sectors will be automatically selected for erasing.
7.
Click
on the “Erase” button. Within a few seconds, you should see the message “Erase
successful!”.
8.
Click
on the “Program button”. Programming may take few seconds to several minutes –
depending on size of .HEX file, speed of your computer and the type of JTAG
cable used. When programming completes, you should see the message “Programming
successful!”.
9.
Close
the flash programming dialog, and from the Run menu, select “Connected to
target, click here to dis-connect”. Finally, from the Run menu, select “Reset
Target (hardware reset)” and your program should run.
Q8. How do I test my program
using MiniARM?
Answer: Refer to the answers of questions:
How do I program the LPC2138 / LPC2104
/ LPC2148?
How do I program the LPC2378 ?
How do I program the STR711 / STR712 ?
After programming the board, you may run the
program. The effects of program execution can be verified by different means,
depending on what the program does.
1.
If
the program performs I/O to serial port (UART), then it will be most convenient
to connect the board to a computer’s COM port with the supplied serial
communication cable. On the computer, you may run SPJTerminal
– which is part of the SCARM C Compiler for ARM.
SPJTerminal is a simple Terminal emulation program (with a few additional
features). From within the SCARM IDE, you may select SPJTerminal from Tools
menu, to start SPJTerminal program. Make appropriate settings under
Port/Settings (generally: no parity, 8 bits per character, 1 stop bit, echo
OFF). Then open port (Port/Open). Now any characters received on the selected
COM port will be displayed in the SPJTerminal window. Further, any character
you type on computer keyboard, will be transmitted over the selected COM port.
Thus any characters transmitted by MiniARM board will be displayed in
SPJTerminal window and characters typed on computer keyboard will be sent to
the MiniARM board. This is based on the assumption that baud rates of computer
(SPJTerminal Port/Settings) and MiniARM board are matching. Baud rate used by
MiniARM board is completely controlled by the program you write.
2.
Similarly,
if the program performs I/O to second serial port (UART1) of LPC21xx, then also
similar setup (as described above) can be used. Connect the supplied “Y”
splitter to MiniARM DB9 connector. At the other end of “Y” splitter are 2 DB9
connectors, marked 0 (UART0) and 1 (UART1). One of these maybe connected to
computer’s COM port via the supplied serial communication cable. Some models of
MiniARM boards (e.g. MiniARM-2378) provide 2 separate DB9 connectors for 2
UARTs. In such cases, the “Y” splitter may not be used.
3.
If
the program uses standard LCD text module, then it is convenient to connect
such an LCD to the board and see results.
4.
If
the program performs I/O on port pins, then it is possible to observe the port
pins status with multi-meter or with oscilloscope. If the pin status is not
changing very fast, then it can be observed with multi-meter (but pin status
must remain steady for at least a few seconds). Alternatively, pin status can
be observed on oscilloscope. Refer to users manual of MiniARM for pin details of
connectors. Do NOT try to observe status directly on IC pins.
Also refer to the ESD-related warning in the users manual.
5.
Another
convenient way to observe port pins status is to use the MA-LED board. It has
42 LEDs connected to port pins. The LED turns ON if corresponding port pin is
LOW. This provides very convenient visual indication of port pins status.