newbie ES question

Discussion in 'Embedded Systems and Microcontrollers' started by newbieEm, Jun 8, 2010.

  1. newbieEm

    Thread Starter New Member

    Jun 8, 2010
    I am newbie to ES. I have this LPC 2370 board with ARM7TDMI processor. I am writing a small LED blinking program. I can see what port used for LED in Processor and change certain bit high and low to blink. My question is I am little confused about concept of 'Port', 'Pin' and 'register'. What are pins? How are they different than ports?

    and in the code here, I am declaring ModeRegister and OutputRegister. Are they actually using registers or Stack? I guess
    by assigning address to the register variables 'OutputRegister = 0xB7A04000;', it points to certain port (or pin)? please clarify. Thanks.

    int main(void)
    int i;
    volatile unsigned char * ModeRegister;
    volatile unsigned char * OutputRegister;

    ModeRegister = 0xB7A04008;
    OutputRegister = 0xB7A04000;

    *ModeRegister = 0x01; // Configure Port E bit 0 as outuput
    while (1)
    *OutputRegister = 0x01; // Set the Port E bit 0 as 1
    for (i=0; i<1000000; i++)
    *OutputRegister = 0x00; // Set the Port E bit 0 as 0
    for (i=0; i<1000000; i++)
  2. zxsa


    Jun 11, 2010
    You picked a difficult processor for starting out in Embedded Systems. Better would have been a small 8-bit microcontroller (like Atmel AVR, or PIC, or 8051).

    When talking about a pin, you are referring the the actual pin of the IC (the metal pin soldered to your PCB). Setting a pin high means to connect the pin to Vcc.

    A port is usually a group of pins. Most microcontroller (and processors) group their IO-pins into ports. The reason is that to address a pin, you need to address a single bit. If you group pins together, you can access all of them using a word (or byte).

    Registers usually refer to actual registers inside the processor. The architecture of 32bit processors becomes complex making it difficult to understand. You pins and ports will have a digital buffer which is the register that you are reading/writing.

    Registers get virtual memory locations. If you look at the detail of your processor, you will find that it places different memory locations (like a flash memory or SRAM or external memory) at different positions in a 32bit address space. The registers for accessing ports and pins and other IO-features, are located at yet another location in the same 32bit address space.

    Your source code sets up pointers to the location in this memory space. By reading/writing these pointers you are directly accessing the actual register.

    Bear in mind that as microprocessors gets more complex (faster and more powerful types than your ARM7TDMI), these concepts gets more and more fuzzy. This is why it's best to start with easier architectures and then gradually move up.

    Hope this helps you.