3 unsigned int compareMatch
=0;
8 init_low_level(); // CPU Frequency & PLL
9 init_pio(); // Map port pins to selected functions
10 init_peripheral(); // UART,Timer,Extint,ADC Enable
11 init_armadillo_tasks();
13 xTaskCreate(led_blink
, ( signed char * ) "Blinky", configMINIMAL_STACK_SIZE
14 ,NULL
, tskIDLE_PRIORITY
+ 2 , NULL
);
15 xTaskCreate(task2
, ( signed char * ) "task2", configMINIMAL_STACK_SIZE
16 ,NULL
, tskIDLE_PRIORITY
+ 3 , NULL
);
18 vTaskStartScheduler();
20 return 0; // Should not reach here unless scheduler fails
23 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 static void led_blink( void *pvParameters
)
26 (void) pvParameters
; //Prevent warning
28 portTickType xLastWakeTime
;
29 portTickType TickCount
;
30 const portTickType xFrequency
= 1; //50
33 xLastWakeTime
= xTaskGetTickCount();
37 vTaskDelayUntil( &xLastWakeTime
, xFrequency
);
38 TickCount
= xTaskGetTickCount();
40 char txbuff
[configUART0_BUFF_SIZE
];
42 if(cnt
%8==0){ // takes 110 us
43 sprintf(txbuff
,"$%4d %s\r",cnt
/8,"seconds");
45 if(xSemaphoreTake(xMutexTX0
,( portTickType
) 1)){
46 serial_pack((unsigned char *)txbuff
);
47 xSemaphoreGive(xMutexTX0
);
52 if(cnt
%8<4){ // Heart Beat
53 if(IOPIN0
&S_LED
)IOCLR0
= S_LED
; else IOSET0
= S_LED
;
61 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 static void task2( void *pvParameters
)
64 (void) pvParameters
; //Prevent warning
66 portTickType xLastWakeTime
;
67 portTickType TickCount
;
68 const portTickType xFrequency
= 9; //50
71 xLastWakeTime
= xTaskGetTickCount();
75 vTaskDelayUntil( &xLastWakeTime
, xFrequency
);
76 TickCount
= xTaskGetTickCount();
78 char txbuff
[configUART0_BUFF_SIZE
];
80 sprintf(txbuff
,"$%4d %s\r",cnt
,"task2");
82 if(xSemaphoreTake(xMutexTX0
,( portTickType
) 1)){
83 serial_pack((unsigned char *)txbuff
);
84 xSemaphoreGive(xMutexTX0
);