Em 13/1/2012 15:08, Andre Abelian escreveu: > Hi all, > > I am testing pic32 and something simple I am having hard time to understa= nd. > I have 2 leds connected to G12 and G14 when I use test1 code LED1 never t= uns on. > test2 and test3 is ok. my question is why test1 is not working. G12 and G= 13 are digital I/O. > if i use debugger step over it works. > > test1: > LED1 =3D 1; > LED2 =3D 0;=20 > delay; > LED1 =3D0; > LED2=3D1; > delay > > > > test2: > if I use & and | logic it works > > LED1 | =3D 1; > LED2 & =3D 0;=20 > delay; > LED1 &=3D0; > LED2 |=3D1; > delay > > test3: > if I use LATGSET and LATGCLR it works > > Since G12 and G14 are not analog pins and I do not have external capacito= r I do not think this is Read modify write issue. > my question is do you know why test1 LED1 stays off when running. > > here is the code. > > while(1) > { > int short_delay; > uint8_t returnStatus1,returnStatus2; // to test > =20 > // led_d7_green &=3D 0; > // led_d8_green |=3D 1; > > // led_d7_green =3D 0; > // led_d8_green =3D 1; > > LATGCLR =3D 0x5000; // 0b0101000000000000; =20 > LATGSET =3D 0x1000; // 0b0001000000000000; > > short_delay =3D 1000*1000; // create short delay > while(short_delay--){}; > > // led_d7_green |=3D 1; > // led_d8_green &=3D 0; > =20 > // led_d7_green =3D 1; > // led_d8_green =3D 0; > =20 > LATGCLR =3D 0x5000; // 0b0101000000000000; =20 > LATGSET =3D 0x4000; // 0b0100000000000000; =20 > =20 > short_delay =3D 1000*1000; // create short delay > while(short_delay--){}; > > } > > thanks=20 > > Andre Probably related to RMW (read-modify-write). When stepping-over or running the code that takes more instructions, there is time for the pin to settle before changing the other pin. When running the faster code at full speed the first pin is read with its previous value and written back with the older value. You are writing to register PORTG, right? Try writing to register LATG instead. Best regards, Isaac --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .