hi, i use software simulator of MDK 4.21 for LPC1114 GPIO. here is the Code:
int main (void) {
int i;
LPC_GPIO[0]->DIR |= (1<<1); //prot0.1 as output
LPC_GPIO[0]->DIR |= (1<<2); //port0.2 as output
while( 1 )
{
LPC_GPIO[0]->MASKED_ACCESS[1<<1] = (1<<1); //set port0.1 as 1
for(i=0;i<10000;i++);
LPC_GPIO[0]->MASKED_ACCESS[1<<2] = (0<<2); //set port0.2 as 0
}
When the first statement(set port0.1 as 1) finished, the simulator work OK, the port0.1 is 1. but when the next statement(set port0.2 as 0) finished, it clear the port0.2 as 0, and Port0.1 has been cleard to 0 also!!
Hi
I am running V4.50 and am also seeing behavior which doesn't agree with my understanding of the documentation when using the Simulator with GPIO. According to the NXP document UM10398, page 115 the GPIODATA register address is ANDed with actual data written to mask the writing of the information through to the output pins. As such if i write:
LPC_GPIO2->MASKED_ACCESS[1 << 5] = 0xfff;
i should just see bit 5 of the output go active BUT i see ALL the pins go active!
This also follows for clearing them, writing a 0 writes through to ALL the bits.
Does anybody else agree with my observations?
I have noticed that a lot of code examples use the following code:
LPC_GPIO2->MASKED_ACCESS[1 << 5] = 1 << 5; // set LPC_GPIO2->MASKED_ACCESS[1 << 5] = ~(1 << 5); // clear
so i was wondering if the simulator IS correct (well it agrees with the hardware) and the documentation is wrong? I have used the Luminary Micro part which behaves in a very similar fashion but only 8 bits and that seems to work fine.
I currently don't have any access to hardware to test this on so have been relying on the simulator.
Thanks for any help that people have had.