2013년 5월 29일 수요일

C Programming Tutorial - Example 1


Run "IAR Embedded Workbench for ARM".



















Click “File-Open-Workspace” in menu.



















Open “RQ.eww” located in /IAR/6.20.4 folder.

















You can see the below C source template.















Input C source in “void main(void) function”.















NOTE)
- puts() 
     => Send “string” to COM port of PC.
           Put double quotation mark(“ “) for string.
           null character (‘\0’) is included in last part of string automatically.
- putch()
     => Send “character” to COM port of PC.
           Put single quotation mark (‘ ‘) for character.
- void User_Task_Every_10ms(void)
     => It is called by every 10msec (1/100 sec), such as timer function.
           It is normally used for regular operation.
-ASCII code
   => \r : Carriage Return  (for current line)

   => \n : Line Feed (next line)





Example #1


#include "user.h
void main(void)
{
  puts("\r\n\nHello, RQ World!\r\n"); //Output String to PC
  putch('R'); //Output a Character to PC
  putch('Q');
}
void User_Task_Every_10ms(void)
{

}



Compile it by click “Project-Make” in menu, or press F7.

















You can see the compile status and result in the below.

 (errors : 0,  warnings : 0)



































Below is connections for each part.

 (PC ó USB cable ó smart controller ó Li-Poly battery)























Run “RQC Firmware Upgrade Tool”.













Click “Browse” button to load Firmware file (RQ.bin)




















RQ.bin file is selected. Check “Keep RQC Internal Setting”.
This maintains basic configuration of RQ smart controller.

,such as (Zero position setting, IR remote controller…)
































“ERROR” message is shown as below
  if RQ smart controller is NOT ready for upload firmware.














Firmware is downloaded to RQ smart controller.




















Run “Hyper Terminal” software.

Put any name in Name section.




















Hyper Terminal available COM port number is shown as Device Manager Ports section is indicated.
In this example, “COM 3” is used for this project.

















HyperTerminal COM port configuration
  (115200 bps, 8bits, None, 1, None)


























You can see “Connected” section in the below section.


















Press “P” button of RQ smart controller,
then, it shows strings in Hyper Terminal through COM port.



댓글 없음:

댓글 쓰기