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

LPC1788

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); }
}

Parents
  • 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 ;
    

Reply
  • 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 ;
    

Children