Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

freeRTOS + wsn430

Posted by Yinxia ZHAO on August 17, 2010
Hi,
I am new to freeRTOS and am debugging some examples of freeRTOS-wsn430 using simulators WSim and WSNet.
When I was testing 05_network_device and 06_coordinator, I can successfully ready ds2411_id and treat it as MAC address
of device. But then, The program steps into preSetupTimerInterrupt() and never goes out.

int main( void )
{
/* Setup the hardware. */
prvSetupHardware();
printf("hardware ready!\n");

/* Create the SPI mutex */
xSPIMutex = xSemaphoreCreateMutex();

/* Create the task of the application */
vCreateMacTask(xSPIMutex, configMAX_PRIORITIES-2);

/* Add the local task */
printf("done\n");
xTaskCreate( vSendingTask, "sender", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES-1, NULL );


/* Start the scheduler. */
vTaskStartScheduler();

/* As the scheduler has been started we should never get here! */
return 0;
}

void vCreateMacTask(xSemaphoreHandle xSPIMutex, uint16_t usPriority) {
/* Stores the mutex handle */
xSPIM = xSPIMutex;

/* Create an Event Queue */
xEventQ = xQueueCreate(5, sizeof(uint8_t));

/* Create a Semaphore for waiting end of TX */
vSemaphoreCreateBinary( xSendingS );
/* Make sure the semaphore is taken */
xSemaphoreTake( xSendingS, 0 );

/* Create the task */
xTaskCreate( vMacTask, "MAC", configMINIMAL_STACK_SIZE, NULL, usPriority, NULL );
// printf("create MAC Task!");
}

static void vMacTask(void* pvParameters) {
uint8_t event;

macState = STATE_ATTACHING;

vInitMac();

/* Network Attachment Procedure */
while (1) {
printf("sending attach request\r\n");
LED_RED_TOGGLE();
vSendAttachFrame();

vStartRx();

uint16_t RXTimeout = 1000;
uint16_t time;
while (1) {
time = xTaskGetTickCount();

if (xQueueReceive(xEventQ, &event, RXTimeout)) {
if (event == EVENT_FRAME_RECEIVED) {
LED_GREEN_OFF();
if (xParseAttachFrame()) {
printf("received attach reply\r\n");
break;
}
}
}
LED_GREEN_ON();

time = xTaskGetTickCount() - time;

if (time < RXTimeout) {
RXTimeout -= time;
} else {
break;
}
}
}

LEDS_OFF();

/* Packet Sending/Receiving */
for (;;) {
vStartRx();
macState = STATE_RX;

while (xQueueReceive(xEventQ, &event, portMAX_DELAY)) {
if (event == EVENT_FRAME_RECEIVED) {
LED_RED_ON();
vParseFrame();
LED_RED_OFF();
} else if (event == EVENT_FRAME_TO_SEND) {
LED_GREEN_ON();
macState = STATE_TX;
vSendFrame();
LED_GREEN_OFF();
}
vStartRx();
macState = STATE_RX;
}
}
}

static void vInitMac(void) {

/* Initialize the unique electronic signature and read it */
ds2411_init();
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
ds2411_id.raw[0], ds2411_id.raw[1], ds2411_id.raw[2], ds2411_id.raw[3],
ds2411_id.raw[4], ds2411_id.raw[5], ds2411_id.raw[6], ds2411_id.raw[7]);

//printf("\nds2411 ready!\n ");

/* XXX hack: Fix it so that the 802.15.4 MAC address is compatible
with an Ethernet MAC address - byte 0 (byte 2 in the DS ID)
cannot be odd. */
//ds2411_id.raw[2] &= 0xfe;
//

//uint16_t i;
//for (i=0;i<6;i++)
//{
//nodeAddr = ds2411_id.raw[i+1];
//}
memcpy(nodeAddr, ds2411_id.raw+sizeof(uint8_t), 6);

printf("nodeAddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
nodeAddr[0],nodeAddr[1],nodeAddr[2],nodeAddr[3],nodeAddr[4],nodeAddr[5]);
printf("coordAddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
coordAddr[0],coordAddr[1],coordAddr[2],coordAddr[3],coordAddr[4],coordAddr[5]);
wsn430_set_rime_addr();

/* Seed the random number generator */
uint16_t seed;
seed = (((uint16_t) ds2411_id.serial0) << 8) + (uint16_t) ds2411_id.serial1;
srand(seed);

/* Leds */
LEDS_INIT();
LEDS_ON();

xSemaphoreTake(xSPIM, portMAX_DELAY);


/* Initialize the radio driver */
/***********************************************************/
cc1100_init();
//printf("cc1100 ready!\n");

cc1100_cmd_idle();

cc1100_cfg_append_status(CC1100_APPEND_STATUS_DISABLE);
cc1100_cfg_crc_autoflush(CC1100_CRC_AUTOFLUSH_DISABLE);
cc1100_cfg_white_data(CC1100_DATA_WHITENING_ENABLE);
cc1100_cfg_crc_en(CC1100_CRC_CALCULATION_ENABLE);
cc1100_cfg_freq_if(0x0C);
cc1100_cfg_fs_autocal(CC1100_AUTOCAL_NEVER);//CC1100_AUTOCAL_4TH_TX_RX_TO_IDLE
//cc1100_cfg_fs_autocal(CC1100_AUTOCAL_4TH_TX_RX_TO_IDLE);
//bpsk
cc1100_cfg_mod_format(CC1100_MODULATION_MSK);

cc1100_cfg_sync_mode(CC1100_SYNCMODE_30_32);

cc1100_cfg_manchester_en(CC1100_MANCHESTER_DISABLE);

cc1100_cfg_txoff_mode(CC1100_TXOFF_MODE_IDLE);
cc1100_cfg_rxoff_mode(CC1100_RXOFF_MODE_IDLE);

// set channel bandwidth (560 kHz)
cc1100_cfg_chanbw_e(0);
cc1100_cfg_chanbw_m(2);

// set data rate (0xD/0x2F is 250kbps)
cc1100_cfg_drate_e(0x0D);
cc1100_cfg_drate_m(0x2F);

uint8_t table[1];
table[0] = 0x67; // -10dBm 0x67 //-5dBm
cc1100_cfg_patable(table, 1);
cc1100_cfg_pa_power(0);

cc1100_cmd_calibrate();

xSemaphoreGive(xSPIM);
}

Can anybody help me please!

RE: freeRTOS + wsn430

Posted by MEdwards on August 18, 2010
I have not idea what this platform is, but I will try and help based on some knowledge of common problems.

1 Most support requests that come from people using simulators end up being bugs in the simulator.

2 I notice you are using printf() in a task. Are you sure the task stack is big enough? Are any other tasks also using IO functions without any sort of guards against re-entrancy or mutual exclusion problems (although prvSetupTimerInterrupt() is called before any tasks run, so I would guess the task code is not relevant to the problem, yet).

3 Does preSetupTimerInterrupt() poll any hardware registers that are not updated by the simulator? Where in prvSetupTimerInterrupt() does the code crash? Can you post the code for that?

RE: freeRTOS + wsn430

Posted by Yinxia ZHAO on August 18, 2010
hi edwards, thank you very much for your reply.
I also suspect that there are bugs in simulators.. But I do not have devices on my hand now, so.....
I tried to comment all the printf(), but the problem is still there..

code went into there there functions and never went out
vTaskIncrementTick();
vTaskSwitchContext();
/* Restore the context of the new task. */
portRESTORE_CONTEXT();

Sorry I am really new to freeRTOS, how to check hardware registers that preSetupInterrupt() poll


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists