Commits

Hazem Selmi committed e395591

Accessing registers under CMSIS + reorganize the tasks

  • Participants
  • Parent commits 54616c1
  • Branches default

Comments (0)

Files changed (1)

 more extensive APIs for additional peripherals and board features, but are
 usually less generic and vendor-specific.
 
+=== accessing registers under CMSIS
+
+When you use CMSIS, you don't need to know the address of any register. That implies that
+you don't need to use `#define` directive to give names for the registers as in experiment-1. 
+All the definitions are in _lpc17xx.h_ which is included at the beginning of your source file when
+a new CMSIS project is opened.
+
+
+You need to know two names to access a register:
+. the name of pointer to the structure instance.
+. The element of structure element:
+
+For GPIO, the name of pointer to the structure instance is:
+
+. LPC_GPIO0   for port-0
+. LPC_GPIO1   for port-1
+. LPC_GPIO2   for port-2
+. LPC_GPIO3   for port-3
+. LPC_GPIO4   for port-4
+
+You can access different registers for each GPIO.
+The three registers used in experiment-1 are (regardless whether your pin is in port0,1,2,3 or 4):
+. FIODIR
+. FIOSET
+. FIOCLR
+
+
+==== Examples:
+
+To control the direction of pins in port-2, you should use the following:
+
+[code,c]
+
+---------------
+LPC_GPIO2->FIODIR
+-------------
+
+
+To set pins in port-1, you should use the following:
+
+[code,c]
+
+---------------
+LPC_GPIO1->FIOSET
+-------------
+
+
+
+===  Connecting external LEDs
+
+.What is LED?
+.How it works?
+.What is the  maximum voltage it can tolerate.
+.If the output voltage is higher than the LED max voltage, what you can do?
+.It should be connected to an output GPIO pin.
+
+==== GPIOs revisited
+
+GPIO is available in all of the I/O pins. A GPIO is pin that can be used as a digital input or digital output pin. 
+Clearly you need a command  to choose the direction of the pin (whether it is used as input or output).
+In this experiment we will choose the direction to make the required pin GPO (general purpose output).
+In this case (GPO), you need a command  to set this output pin to HIGH (1) and a command to Clear it to LOW (0).
+  
+
 == Tasks
 
-=== Import CMSIS Libraries
+=== Hardware:
+
+. Choose I/O Pins
+
+. Connect the LEDs using a proper current limiting resistor.
+
+=== Software
+
+==== Import CMSIS Libraries
 
 . Run LPCXpresso IDE. Choose a new workspace, e.g. `cmsis_workspace`.
 
 . Keep both projects selected: `CMSIS_CORE_LPC17xx` and
   `CMSIS_DSPLIB_CM3`, and click _Finish_.
 
-=== Blink 4 External LEDs  
+==== open a new project
 
-==== Choose I/O Pins
+==== Write a Program to perform LED scrolling 
 
-==== Connect the LEDs
+in the source file of your project write a code to make it looks like that a light is scrolling through your 4 LEDs.
+You can achieve that by turning  LEDs ON sequentially.  
 
-==== Write a Program
-
-===