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

LPC2368 is not working with RL-ARM and MDK 3.70

Without use the RTOS noticed that the clock processing decreases. Using the RTOS does not work.

Parents
  • Now why do you think that it is ok to write a delay loop in C and expect a known delay?

    If you want to busy-loop for 1000ms, program a timer to tick at 1kHz, and have the loop wait for 1000 ticks. Either use an interrupt, or constantly poll the timer. But you have to base the delay on a known constant. If you really do want to delay based on instruction cycles, do use assembler so you know exactly how many instruction cycles your loop takes.

    With your code, the produced instructions may change between two compiler versions. Having register variables or volatile variables will make a great change. Flash acceleration on or off may make a big difference too. In the end, you may even get a zero-delay loop because the compiler may throw away all code when it notices that your delay function doesn't have any side effects.

    And also remember that the instructions produced for the loop will be greatly affected by any optimization switches. And any change of clock speed will require you to spend a lot of time adjusting your loop constants.

    Another thing: Why bother with comments that are not comments? Your comments "Bibliotecas incluidas", "Delay" and "MAIN" don't exactly add any extra value to the program. Do write comments about the purpose of the functions. Your delay function most definitely takes a parameter. And you haven't described why you think it will produce a 1ms delay.

    And how will you, three monthrs from now know what the following line does?

    SCS =  0x00000031;
    

Reply
  • Now why do you think that it is ok to write a delay loop in C and expect a known delay?

    If you want to busy-loop for 1000ms, program a timer to tick at 1kHz, and have the loop wait for 1000 ticks. Either use an interrupt, or constantly poll the timer. But you have to base the delay on a known constant. If you really do want to delay based on instruction cycles, do use assembler so you know exactly how many instruction cycles your loop takes.

    With your code, the produced instructions may change between two compiler versions. Having register variables or volatile variables will make a great change. Flash acceleration on or off may make a big difference too. In the end, you may even get a zero-delay loop because the compiler may throw away all code when it notices that your delay function doesn't have any side effects.

    And also remember that the instructions produced for the loop will be greatly affected by any optimization switches. And any change of clock speed will require you to spend a lot of time adjusting your loop constants.

    Another thing: Why bother with comments that are not comments? Your comments "Bibliotecas incluidas", "Delay" and "MAIN" don't exactly add any extra value to the program. Do write comments about the purpose of the functions. Your delay function most definitely takes a parameter. And you haven't described why you think it will produce a 1ms delay.

    And how will you, three monthrs from now know what the following line does?

    SCS =  0x00000031;
    

Children