lpcware

Selecting I2C pin as GPIO. - LPC1317 - 48P

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by aamir ali on Thu Feb 21 03:31:44 MST 2013
1. I have to select P0.4 & P0.5 as standard I/O.

Wich of 3 is correct way of it:

1. LPC_IOCON->PIO0_4 = 0x00000100;   //Pin as standard I/O function, //write all reserved bits as zero.


2. LPC_IOCON->PIO0_4 = 0x00000180;   // according to ARMWizard, web: //http://alexan.edaboard.eu/


3. LPC_IOCON->PIO0_4 =  (LPC_IOCON->PIO0_4 & 0xFFFFFCF8) | 0x0100; //mask //out reserved values & then write values


2. Also I made Pin0.4 & 0.5 as output by:

    LPC_IOCON->PIO0_4 = 0x00000100;    
    LPC_IOCON->PIO0_5 = 0x00000100;   
    LPC_GPIO->DIR[0] |= 0x00000030;


   Now how to drive pin low & open drain mode. Following values doesn't seem to work:

     
  LPC_GPIO->W0[4] == 0;
        LPC_GPIO->W0[5] == 0;
        LPC_GPIO->W0[4] == 1;
        LPC_GPIO->W0[5] == 1;


3. Also pins like P0.3 has bits 7,8,9 reserved as 1.
   So while selecting it for output, what should I use:


Quote:
    LPC_IOCON->PIO0_3 = 0x00000080;      // 8 represent the reserved bit, output with no resistor
or  LPC_IOCON->PIO0_3 = 0x00000000;      
or  LPC_IOCON->PIO0_3 =  (LPC_IOCON->PIO0_3 & 0xFFFFFB80) | 0x0000;



As in datashhet its mentions that


Quote:
user software should not write ones to reserved bits.
The value read from a reserved bit is not defined.



[B][I][U]But what to do if reserved pins are 1 as in this case. Should I write zero to them[/U][/I][/B]

Outcomes