This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

read voltage on pin mcb2300

Dear All,

I have a mcb2300 board with LPC2378. I want to read the voltage with Test Multimeter from PIN0.0. I read from Document that this pin corresponds to the PIN 66 on the board. So I set pin 66 with this code:

PINSEL0 |= 0x00000000;

but I read on the Test Multimeter 4.66 voltage.

Why no 0 volts?

Thanks

Miky

  • I guess you are quite new with C and∨ C++.

    PINSEL0 |= 0x00000000
    


    This is a null operation - you are basically adding 0 to the register, so you don't change anything.

    Another thing: PINSEL0 controls the function of the first 16 port pins of PORT0. It does not change the state of any pin, i.e. setting it high or low.

    To change the state of a pin, you should instead use IO0SET or - if you have enabled fast GPIO - FIO0SET.

    But first you have to set the pin as an output, with either IO0DIR or FIO0DIR as:

    IO0DIR |= 1u << 0; // set P0.0 as output
    IO0DIR |= 1u << 1; // set P0.1 as output
    ...
    IO0DIR |= 1u << 31; // set P0.31 as output
    
    IO0DIR &= ~(1u << 0); // set P0.0 as input
    IO0DIR &= ~(1u << 1); // set P0.1 as input
    ...
    IO0DIR &= ~(1u << 31); // set P0.31 as input
    

    Then you can control the bits on the port:

    IO0SET = 1u << 0; // set P0.0.
    IO0SET = 1u << 1; // set P0.1.
    ...
    IO0SET = 1u << 31; // set P0.31.
    

    IO0CLR = 1u << 0; // clear P0.0
    IO0CLR = 1u << 1; // clear P0.1
    ...
    IO0CLR = 1u << 31; // clear P0.31

    Take a look at the example programs. There are documented code that plays with the LED on the board.