#define TASK_TEMPLATE_LIST_END {0, 0, 0, 0, 0, 0, 0}
/* MQX task template list */
const TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
/* Task: InitTask */
{
/* Task number */ INITTASK_TASK,
/* Entry point */ (TASK_FPTR)InitTask,
/* Stack size */ INITTASK_TASK_STACK_SIZE,
/* Task priority */ 8U,
/* Task name */ "inittask",
/* Task attributes */ (MQX_AUTO_START_TASK),
/* Task parameter */ (uint32_t)(0)
},
/* Task: LEDTask */
{
/* Task number */ LEDTASK_TASK,
/* Entry point */ (TASK_FPTR)LEDTask,
/* Stack size */ LEDTASK_TASK_STACK_SIZE,
/* Task priority */ 10U,
/* Task name */ "ledtask",
/* Task attributes */ (0),
/* Task parameter */ (uint32_t)(0)
},
/* Task: GR_LED_ON */
{
/* Task number */ GR_LED_ON_TASK,
/* Entry point */ (TASK_FPTR)GR_LED_ON,
/* Stack size */ GR_LED_ON_TASK_STACK_SIZE,
/* Task priority */ 9U,
/* Task name */ "gr_led_on",
/* Task attributes */ (0),
/* Task parameter */ (uint32_t)(0)
},
TASK_TEMPLATE_LIST_END
};
/* ###################################################################
** Filename : mqx_tasks.c
** Project : ProcessorExpert
** Processor : MKL25Z128VLK4
** Component : Events
** Version : Driver 01.00
** Compiler : GNU C Compiler
** Date/Time : 2013-05-27, 17:44, # CodeGen: 0
** Abstract :
** This is user's event module.
** Put your event handler code here.
** Settings :
** Contents :
** InitTask - void InitTask(uint32_t task_init_data);
**
** ###################################################################*/
/*!
** @file mqx_tasks.c
** @version 01.00
** @brief
** This is user's event module.
** Put your event handler code here.
*/
/*!
** @addtogroup mqx_tasks_module mqx_tasks module documentation
** @{
*/
/* MODULE mqx_tasks */
#include "Cpu.h"
#include "Events.h"
#include "mqx_tasks.h"
#ifdef __cplusplus
extern "C" {
#endif
/* User includes (#include below this line is not maintained by Processor Expert) */
#define RED_LED_LOC (1<<18)
#define GREEN_LED_LOC (1<<19)
#define BLUE_LED_LOC (1<<1)
#define RED_LED_OFF GPIOB_PSOR = RED_LED_LOC
#define RED_LED_ON GPIOB_PCOR = RED_LED_LOC
void Delay(int Ticks)
{
int i;
for(i=0;i<Ticks;i++)
{
}
}
/*
** ===================================================================
** Event : InitTask (module mqx_tasks)
**
** Component : Task1 [MQXLite_task]
** Description :
** MQX task routine. The routine is generated into mqx_tasks.c
** file.
** Parameters :
** NAME - DESCRIPTION
** task_init_data -
** Returns : Nothing
** ===================================================================
*/
void InitTask(uint32_t task_init_data)
{
//First order of business is to enable the Clocks to the ports!
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTD_MASK;
//Now, setup the port mux for GPIO! See Page 163 and 183 of KL25 Sub-Family Reference Manual, Rev. 3, September 2012
PORTB_PCR18 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;
PORTB_PCR19 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;
PORTD_PCR1 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;
//Set the GPIO to outputs in the data direction register
//See Page 778 of KL25 Sub-Family Reference Manual, Rev. 3, September 2012
GPIOB_PDDR |= RED_LED_LOC | GREEN_LED_LOC;
GPIOD_PDDR |= BLUE_LED_LOC;
RED_LED_OFF;
/* _task_id task_id;
task_id=_task_create_at(0, LEDTASK_TASK, 0, LEDTask_task_stack, LEDTASK_TASK_STACK_SIZE);
if(task_id=MQX_NULL_TASK_ID){
printf("\n can not create led task");
}else{
printf("\n LED task created");
}
task_id=_task_create_at(0, GR_LED_ON_TASK, 0, GR_LED_ON_task_stack, GR_LED_ON_TASK_STACK_SIZE);
if(task_id=MQX_NULL_TASK_ID){
printf("\n can not create led task");
}else{
printf("\n LED task created");
}*/
_task_create_at(0, GR_LED_ON_TASK, 0, GR_LED_ON_task_stack, GR_LED_ON_TASK_STACK_SIZE);
_task_create_at(0, LEDTASK_TASK, 0, LEDTask_task_stack, LEDTASK_TASK_STACK_SIZE);
}
/*
** ===================================================================
** Event : LEDTask (module mqx_tasks)
**
** Component : Task2 [MQXLite_task]
** Description :
** MQX task routine. The routine is generated into mqx_tasks.c
** file.
** Parameters :
** NAME - DESCRIPTION
** task_init_data -
** Returns : Nothing
** ===================================================================
*/
void LEDTask(uint32_t task_init_data)
{
int value=0;
while(TRUE)
{
//The dedicated GPIO Set and clear registers make bit banging easier. Just write to the port what bits
//you want set or cleared. The or-ing / not-anding is done in *hardware*
//see pages 775 - 778 of KL25 Sub-Family Reference Manual, Rev. 3, September 2012
// RED_LED_OFF;
// Delay(1000000);
GPIOB_PSOR = GREEN_LED_LOC;
Delay(1000000);
GPIOD_PSOR = BLUE_LED_LOC;
Delay(1000000);
// RED_LED_ON;
// Delay(1000000);
GPIOB_PCOR = GREEN_LED_LOC;
Delay(1000000);
GPIOD_PCOR = BLUE_LED_LOC;
Delay(1000000);
value=value^1;
}
}
/*
** ===================================================================
** Event : GR_LED_ON (module mqx_tasks)
**
** Component : Task3 [MQXLite_task]
** Description :
** MQX task routine. The routine is generated into mqx_tasks.c
** file.
** Parameters :
** NAME - DESCRIPTION
** task_init_data -
** Returns : Nothing
** ===================================================================
*/
void GR_LED_ON(uint32_t task_init_data)
{
int value=0;
while(TRUE)
{
//The dedicated GPIO Set and clear registers make bit banging easier. Just write to the port what bits
//you want set or cleared. The or-ing / not-anding is done in *hardware*
//see pages 775 - 778 of KL25 Sub-Family Reference Manual, Rev. 3, September 2012
/* GPIOB_PSOR = GREEN_LED_LOC;
Delay(1000000);
GPIOD_PSOR = BLUE_LED_LOC;
Delay(1000000);*/
RED_LED_ON;
Delay(1000000);
/* GPIOB_PCOR = GREEN_LED_LOC;
Delay(1000000);
GPIOD_PCOR = BLUE_LED_LOC;
Delay(1000000);*/
RED_LED_OFF;
Delay(1000000);
value=value^1;
}
}
/* END mqx_tasks */
#ifdef __cplusplus
} /* extern "C" */
#endif
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.2 [05.06]
** for the Freescale Kinetis series of microcontrollers.
**
** ###################################################################
*/
Thanks
I have also attached my code warrior project..
Original Attachment has been moved to: Freescale_MQL_test1.rar.zip
Solved! Go to Solution.
instead of Delay(), use the MQX Lite blocking function _time_delay_ticks();
instead of Delay(), use the MQX Lite blocking function _time_delay_ticks();
Hi Martin,
If followed your instructions and Now The program works.
Thank you very much for replying.
Regards
Yogesh