Jump to content

Antonio Pires

EstablishedMember
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Antonio Pires

  • Rank
    Newbrie
  1. Dear all, Problem fixed... The problem was no related to the rtos but with a directive: Task2 code is dependent of the TEST_MODE directive. This directive was mispelled in the code as TESTMODE. In this way the code was never generated and off course no task could run. thanks A. Pires
  2. Sorry but that is not true. 1. For Task2 I initialise the hTestRun semaphore in the main(). I incremented 10 times this semaphore in order for Task 2 to run 10 iteractions. 2. Both semaphores hI2CCmdRcvd and hSerPktRdy are signaled in interrupt routines. After power up, only Task2 should run because there are no activity in the I2C bus neither in the RS232 link. Please find below the the code built in the interrupt vector. For the I2C (only an extract) =================== ....... //--------------------------------------------------------------------- // STATE 5: A NACK from the master device is used to indicate that a // complete transmission has occurred. The clearing of the // WDT is reenabled in the main loop at this time. //--------------------------------------------------------------------- else if(stat_da && !stat_rw && !stat_bf) { slv_stat.wdtdis = 0; clear_wdt(); LED_0 = OFF; slv_stat.cmdrcvd = 1; SysSignalSemaphoreIsr(hI2CCmdRcvd); } else; } ............ For the RS232 ========== void getpkt(void) { switch (state) { case PKT_WAIT_START: if (NewChar == 'P') { sptr = &batstr[0]; state++; } break; case PKT_WAIT_DATA: if (NewChar != '%') { *sptr++ = NewChar; } else { *sptr=0; state = PKT_COMPLETE; } break; case PKT_COMPLETE: SysSignalSemaphoreIsr(hSerPktRdy); break; default: state = PKT_WAIT_START; break; } } I realy do not understand what is happening. I followed all the correct procedures. Thanks. A. Pires
  3. Can somebody tell me why this code does not multitask: #include <system.h> #include <stdlib.h> #include <novocfg_pic16t3e5ts1.h> #include <novo.h> #include "cpucfg.h" #include "I2Cslv.h" #include "soldrv.h" ... // Novo RTOS tasks - high priority task first #define hTask0 0 // Scheduler #define hTask1 1 // Battery Task #define hTask2 2 // Test // Task priorities #define HI_PRIO 2 // Novo RTOS Semaphores #define hI2CCmdRcvd 0 // I2C semaphore #define hSerPktRdy 1 // Serial semaphore #ifdef TESTMODE #define hTestRun 3 // Test #endif ... void Task0(void) { unsigned char ch; while (1) { Sys_WaitSemaphore(hI2CCmdRcvd, EVENT_NO_TIMEOUT); switch ( ch=I2C_GetCmd(0)) { // Solenoids case 1: case 2: case 3: case 4: case 5: case 6: unsigned char mode=I2C_GetCmd(1); activateSolenoid(ch,mode); break; // Digital Inputs case 7: readInputs(); break; // Initiate Bat Msg decoding #ifdef USE_BATTERY case 8: Initialise(); serEnable(); startBatdecode(); break; // Read Battery status case 9: getBatStatus(); break; #endif // Test Solenoids case 11: case 12: case 13: case 14: case 15: case 16: testSolenoids(ch-10); break; // Healthy msg case 20: I2C_SendDataByte(FLAG,'O'); break; default: break; } Sys_Yield(); } } void Task1(void) { while (1) { #ifdef USE_BATTERY Sys_WaitSemaphore(hSerPktRdy, EVENT_NO_TIMEOUT); Power = decode("ower:"); Volts = decode("Voltage:"); Current = Power / (Volts/10); Charge = decode("Avg Charge:"); Sys_Sleep(50);//Sleep 500 ms Initialise(); Sys_Yield(); #else Sys_Sleep(200);// Sleep 2 segs Sys_Yield(); #endif } } void Task2(void) { while (1) { #ifdef TESTMODE Sys_WaitSemaphore(hTestRun, EVENT_NO_TIMEOUT); porta = 0x0F; Sys_Sleep(50); porta = 0x00; Sys_Sleep(50) #else Sys_Sleep(200); #endif Sys_Yield(); } } void main(void) { #ifdef TESTMODE unsigned char i; #endif InitHW(); SysInit(); SysCreateTask(hTask0,HI_PRIO,Task0);// Scheduler task SysCreateTask(hTask1,HI_PRIO,Task1);// Battery task SysCreateTask(hTask2,HI_PRIO,Task2); SysStartTask(hTask0); SysStartTask(hTask1); SysStartTask(hTask2); #ifdef TESTMODE for (i = 0; i < 10; i++) { SysSignalSemaphore(hTestRun); } #endif // Background Task while (1) { if(!isWDTdis()) { clear_wdt(); } Sys_Yield(); } } The code has 3 tasks. When initially running, task2 should run during around 10 secs until the semaphore reaches zero, while task0 and task1 should be blocked waiting for a semaphore. The code compiles well, I use MPLAB IDE v8.30, BoostC v6.95 and boostlink 6.95. I use the -swcs in the boostlink. I've tryied everything.........I'm stucked! Thanks A. Pires
  4. Do you use the linker command line option -swcs, this is required in order to use the software call stack that Novo RTOS needs. Regards Dave I forgot that detail...sorry for wasting your time...It works fine now. Thanks Dave.
  5. I'm trying to convert an existing project to work with NOVO RTOS. The project consists of two main files. One is the I2C network driver where I have a ISR to deal with I2C comms based protocol. In this ISR every time a frame is received it signals a semaphore using the SysSignalSemaphore function. In the main file I have two tasks, one is simply a blink led control task which uses the sleep primitive. The other task is responsible for processing the I2C frame information already buffered. It waits for a semaphore (signalled by the ISR) and then process the I2C info and wait again for the semaphore. The problem is that neither the tasks run. I would like to know what can be happening. Here are some extracts from the code: ISR ( a separate module) ======================== void SLV_I2C_Handler(void) { ................ if(stat_da && !stat_rw && !stat_bf) { LED_0 = OFF; slv_stat.cmdrcvd = 1; SysSignalSemaphoreIsr(hSemCmdRcv); } } Main program ============ 1) Includes #include <system.h> #include <stdio.h> #include <novocfg_pic16t3e5ts1.h> #include <novo.h> #include "cpucfg.h" #include "I2Cslv.h" 2) Tasks // Novo RTOS #define hTask0 0 #define hTask1 1 #define hSemCmdRcvd 0 void Task0(void) { unsigned int rawval; while (1) { Sys_WaitSemaphore(hSemCmdRcvd, EVENT_NO_TIMEOUT); switch (I2C_GetCmd(0)) { case 0: // Read Temperature - Regs 0-1 rawval = hMeasureTemp(); I2C_SendDataWord(0, rawval); break; case 1: // Read Humidity - Regs 2-3 rawval = hMeasureHum(); I2C_SendDataWord(2, rawval); break; default: break; } Sys_Yield(); } } void Task1(void) { static bit lit=0; while (1) { lit = ! lit; portb.1 = lit; Sys_Sleep(10); Sys_Yield(); } } 3) Main void main(void) { InitHW(); hConnectionReset(); delay_ms(100); InitTimer(); SysInit(); SysCreateTask(hTask0,2,Task0); SysCreateTask(hTask1,2,Task1); SysStartTask(hTask0); SysStartTask(hTask1); while (1) { Sys_Yield(); } } 4) Interrupt vector void interrupt( void ) { // Handle SSP interrupt if(sspif) { LED_0 = ON; // Turn on LED to indicate I2C activity. sspif = 0; // Clear the interrupt flag. SLV_I2C_Handler(); // Do I2C communication } // Handle Timer 1 interrupt if (tmr1if) { tmr1if=0; // Clear Interrupt flag SysTimerUpdate(); tmr1l = 0x2b; // 25 ms tmr1h = 0xcf; } } The projects compiles and links well without errors and I' using the appropriate libs. Can you help? Thank you.
×
×
  • Create New...