.. _lab5: How to use ARC board ####################### Purpose ======= - To get familiar with the usage of ARC board and on-board peripherals - To know how to program and debug the ARC board and on-board peripherals Requirements ============ The following hardware and tools are required: * PC host * |arcgnu| / |mwdt| * ARC board (|emsk| / |iotdk|) * ``embarc_osp/arc_labs/labs/lab5_emsk`` / ``embarc_osp/arc_labs/labs/lab5_iotdk`` Content ======== - A brief introduction of ARC board and on-board peripherals - Based on |embarc|, program the GPIO to control some on-board peripherals .. note:: About the detailed usage of |embarc|, see `How to use embARC OSP `__ Principles ========== |emsk| ******* About the brief introduction of |emsk|, see to `embARC OSP Documentation `__ There are LEDs, DIP switches, and buttons on |emsk|, this lab shows how to program the GPIO to control these on-board peripherals of |emsk|. The code for this lab is located in ``embarc_osp/arc_labs/labs/lab5_emsk``. In the code, the on-board buttons and DIP switches' values are read, and whether LEDs are on or off depend on the value of the buttons and DIP switches. |iotdk| ******* About the brief introduction of |iotdk|, see `embARC OSP Documentation `__ As there are no LED or other easy-to-use peripherals on |iotdk|, this lab shows how to control a LED through the arduino interface of |iotdk|. The code for this lab is located in ``embarc_osp/arc_labs/labs/lab5_iotdk``. In the code, the external connected LED blinks periodically. Steps ===== |emsk| ****** 1. Connect |emsk| to your computer, select **em7d** configuration and open UART terminal. 2. Compile and run the ``embarc_osp/arc_labs/lab5_emsk`` example with the following commands: .. code-block:: console cd /arc_labs/lab5_emsk make BOARD=emsk BD_VER=22 CUR_CORE=arcem7d TOOLCHAIN=gnu run 3. Press the buttons (L or/and R) and toggle the DIP switches (3 or/and 4), then check the result in UART terminal, and watch the changes of on-board LEDs. |figure1| |iotdk| ******* |iotdk| has an arduino interface, here select arduino digital pinout **ARDUINO_PIN_0(iotdk gpio4b_2[0])** to control LED. 1. Find a LED, connect the LED anode pin to **ARDUINO_PIN_0**, connect the LED cathode pin to **GND** of |iotdk|. 2. Connect the USB cable to the USB data port of |iotdk| and the computer. 3. Compile and run the ``embarc_osp/arc_labs/lab5_iotdk`` example with the following commands: .. code-block:: console cd /arc_labs/lab5_iotdk make BOARD=iotdk TOOLCHAIN=gnu run 4. Watch the changes of external connected LED. |figure2| .. note:: The connection between LED and |iotdk| is just for test. A 1kΩ resistor should be added in series connection to limited the current and prevent damage to I/O pin. Exercises ========= Try to create you own application to control the peripherals of ARC board .. note:: The ARC |iotdk| is powered over USB. Note that the ARC |iotdk| needs to be powered by an external power adapter if additional devices are connected to the extension interfaces. External power supply must be 5V DC (A 12V power supply will most probably damage your board). .. |figure1| image:: /img/lab5_emsk.png :alt: lab5_emsk :width: 400 .. |figure2| image:: /img/lab5_iotdk_pin_connect.png :alt: lab5_iotdk_pin_connect :width: 400