hi dears
i use this code on keil v5.16a. when i clear a register , the pin position dont chane to 0, and it stay o 1. but in version 4.7 it works correctly. thank you.
#include "LPC177x_8x.h"
#define t 2000
void Delay (uint32_t Time) { uint32_t i;
i = 0; while (Time--) { for (i = 0; i < 50; i++); } }
int main (void) { // ---------------- Configuration ---------------
LPC_GPIO3->DIR = 1<<25 ; /* LEDs PORT3.25 are Output */ while(1) {
LPC_GPIO3->SET = 1<<25; Delay(t);
//LPC_GPIO3->DIR->CLR = 1<<25 ; LPC_GPIO3->CLR = 1<<25; Delay(t); } }
1) Did you think the code would be too easy to read if you followed the posting instructions and used the proper tags around the source code?
2) How do you know if set/clear works? With your very scruffy delay, it's likely your LED will flash on/off at a very high frequency and you will just see them glowing at 50% intensity instead of noticing that they actually blinks.
3) Why do you keep this line, which is so very obviously broken? Since when does the DIR register become a pointer to a structure that has a field named CLR?
//LPC_GPIO3->DIR->CLR = 1<<25 ;
2-Because I test this on simulator I set the time very short. I test it on simulator on version 4.7 and 5.16 About note 3 the LPC_GPIO3->DIR->CLR = 1<<25 ; That is enable but I when I was writing I had mistake. Thanks a lot.
But note that when you run on the real hardware, your delay will be shorter. Maybe much shorter. The compiler is even free to totally remove your busy-loop since it doesn't produce any meaningful side effect the compiler can see.
Have you on the real hardware checked the pin with an oscilloscope?
I use keil 5.16a the problem is in simulator and elevation board. when in lpc1788 i set gpio3 direction output (like LPC_GPIO3->DIR = 1<<25 ;) and set every fio3set (like LPC_GPIO3->SET = 1<<25;)as 1 any fio3pin position don't change to 1. but in other ports every thing is ok. you can try this in General Purpose Input/Output 3 (GPIO3) window.
in keil 4.7 there is not this problem.
best regards