Dear all,
My project use RTX base on Cortex-m0 lpc1114. The task1 configure the P0_2 as output and control the led, it works. The task2 configure the P0_1 as clkout pin, and configure the clkout connect to main clock, but it doesn't works.
But clkout pin is ok, when i remove the RTX.
Please help me, Thank you! code: #include <LPC11xx.h> #include <RTL.h>
OS_TID id1, id2 ;
__task void task1(void) ; __task void task2(void) ;
__task void task1(void) { id1 = os_tsk_self() ; id2 = os_tsk_create(task2, 1) ;
for(;;) { os_evt_set(0x0002, id2) ; os_evt_wait_or(0x0004, 0xffff) ; LPC_GPIO0->DATA = 0x00000000 ; os_dly_wait(100) ;
} }
__task void task2(void) { for(;;) { os_evt_wait_or(0x0002, 0xffff) ; LPC_GPIO0->DATA = 0x0000000f ; os_dly_wait(100) ; os_evt_set(0x0004, id1) ;
int main(void) { LPC_GPIO0->DIR = 0x0000000f ; LPC_GPIO0->DATA = 0x0000000f ; LPC_IOCON->RESET_PIO0_0 = 0x00000001 ; LPC_IOCON->PIO0_1 = 0x00000001 ; LPC_IOCON->PIO0_2 = 0x00000011 ; LPC_SYSCON->CLKOUTCLKSEL = 0x00000003 ; LPC_SYSCON->CLKOUTDIV = 0x00000001 ; LPC_SYSCON->CLKOUTUEN = 0x00000000 ; LPC_SYSCON->CLKOUTUEN = 0x00000001 ; os_sys_init(task1) ; }
My project run without RTX, the clkout pin can output the "main clock". So why the project run with RTX can't output the "main clock". Thank you for your help! Help
#include "LPC11xx.h" /* LPC11xx Peripheral Registers */ #include "gpio.h" void Delay(uint32_t nCount) { for(; nCount != 0; nCount--); } /***************************************************************************** ** Main Function main() ******************************************************************************/ int main (void) { SystemInit(); GPIOInit(); GPIOSetDir( PORT0, 0, 1 ); //P0.1 is output(LED2) GPIOSetDir( PORT0, 2, 1 ); //P1.8 is output(LED1) LPC_IOCON->RESET_PIO0_0 = 0x00000001 ; LPC_IOCON->PIO0_1 = 0x00000001 ; LPC_SYSCON->CLKOUTCLKSEL = 0x00000003 ; LPC_SYSCON->CLKOUTDIV = 0x00000001 ; LPC_SYSCON->CLKOUTUEN = 0x00000000 ; LPC_SYSCON->CLKOUTUEN = 0x00000001 ; while(1) { GPIOSetValue( PORT0, 0, 0 ); GPIOSetValue( PORT0, 2, 1 ); Delay(1000000); GPIOSetValue( PORT0, 0, 1 ); GPIOSetValue( PORT0, 2, 0 ); Delay(1000000); } }
So don't use RTX, then!
You really don't need it for a simple project like this.
What is your actual goal in using it?
Have you spent time studying its documentation, working through examples, tutorials, etc?
Thanks for Andrew's reply. This simple project just for testing of RTX run in cortex-m0. I have also run the same test in cortex-m3, it works well. I just don't understand why it fail at cortex-m0. Yeah, I had spent my time studying the RTX.
My desire is that the RTX can be used at my product RFID Reader Device.
No one wants to read the source code in the first post, because of the missed formatting.
But the question is: Have you debugged the code? What did you learn by single-stepping the code lines while looking at the status of the relevant processor registers?
Dear Pre Westermark,
I had read the source code of uC/OS-II before, so i just read the user guide of RTX. I have debuged the code by keil. The keil simulator show the processor registers is all right. But when i release the code, and download to my target, it doesn't works.
Why did you tag your answer as if it was source code? Did it felt like source code? Do you see other people on this forum tag their answers as source code?
"The keil simulator show the processor registers is all right"
So you have looked at registers in the simulator. But have you debugged the program on the real target? Is there, then, any difference in what values all relevant registers stores in relation to your program without RTX?
Dear Pre Westermark
I tag the answer as source code that run without RTX just for compare. The source code execute the same operation than that run with RTX. If it's wrong to tag the source code on this forum, you get my apologize. Yeah, but i have not tools for debuging real target. and same test in Cortex-m3 core is well. That is my problem. Why this problem happen at cortex-m0.
http://www.keil.com/forum/tips.asp
This is ordinary text - or "prose" - do not use the source code tags for the ordinary text of the messages that you write.
You can add emphasis with Bold or Italic or Bold+Italic
Only use the source code tags to enclose source code - like this:
__task void task1(void) { id1 = os_tsk_self() ; id2 = os_tsk_create(task2, 1) ; for(;;) { os_evt_set(0x0002, id2) ; os_evt_wait_or(0x0004, 0xffff) ; LPC_GPIO0->DATA = 0x00000000 ; os_dly_wait(100) ; } }
If you post source code without using the source code tags, you get a mess like this:
__task void task1(void) { id1 = os_tsk_self() ; id2 = os_tsk_create(task2, 1) ;for(;;) { os_evt_set(0x0002, id2) ; os_evt_wait_or(0x0004, 0xffff) ; LPC_GPIO0->DATA = 0x00000000 ; os_dly_wait(100) ;}
Thanks for your notification
You're welcome.
Not so hard - is it?!
But first off, the simulator may do something wrong. It isn't the real thing. Just an attempt at behaving identical to the real chip.
The next thing - how do you know that not one of the important important registers aren't either write-protected? And how do you know that os_sys_init() isn't overwriting any of your settings?
About source code - notice that you have still not bothered to repost the source code from your original post, to make it readable. No one will really bother to look closer at that source code, as it is currently garbled because of the lack of the proper tags.
Dear Person Westermark,
#include <LPC11xx.h> #include <RTL.h> OS_TID id1, id2 ; __task void task1(void) ; __task void task2(void) ; __task void task1(void) { id1 = os_tsk_self() ; id2 = os_tsk_create(task2, 1) ; for(;;) { os_evt_set(0x0002, id2) ; os_evt_wait_or(0x0004, 0xffff) ; LPC_GPIO0->DATA = 0x00000000 ; os_dly_wait(100) ; } } __task void task2(void) { for(;;) { os_evt_wait_or(0x0002, 0xffff) ; LPC_GPIO0->DATA = 0x0000000f ; os_dly_wait(100) ; os_evt_set(0x0004, id1) ; } } int main(void) { LPC_GPIO0->DIR = 0x0000000f ; LPC_GPIO0->DATA = 0x0000000f ; L PC_IOCON->RESET_PIO0_0 = 0x00000001 ; LPC_IOCON->PIO0_1 = 0x00000001 ; LPC_IOCON->PIO0_2 = 0x00000011 ; LPC_SYSCON- >CLKOUTCLKSEL = 0x00000003 ; LPC_SYSCON->CLKOUTDIV = 0x00000001 ; LPC_SYSCON->CLKOUTUEN = 0x00000000 ; LPC_SYSCON->CLKOUTUEN = 0x00000001 ; os_sys_init(task1) ; }
IS that really how you lay out your source code?
Do you really think that is clear and easy to read?