Pumpkin, Inc.

Pumpkin User Forums

Pic18 + C18 + OSDelay (major trouble)

For issues specific to Microchip's PICmicro® MCUs, including compilers (e.g. HI-TECH PICC & PICC-18, Microchip MPLAB®-C18) and IDEs (e.g. Microchip MPLAB®).

Re: Pic18 + C18 + OSDelay (major trouble)

Postby Daani4all » Thu Jan 13, 2011 2:36 pm

first of all, THANK YOU SO MUCH for even taking your time answering me.
I have that pdf open :D

not succeded yet.


----------------------------------------------------------------------
Debug build of project `D:\Tekniska H
Daani4all
 
Posts: 14
Joined: Wed Dec 01, 2010 4:29 pm

Re: Pic18 + C18 + OSDelay (major trouble)

Postby aek » Thu Jan 13, 2011 2:55 pm

It looks to me like maybe you copied something from mem.c into your file(s).

1. Remove the -DMAKE_WITH_FREE_LIB -DSYSE symbol definitions from your project. You are not using them.

2. I would uninstall, delete and reinstall Salvo to ensure that you have a fresh, complete build.

The rest of your stuff looks fine.

All you need is your main.c, Salvo's mem.c, and a Salvo library, to build. It looks like either

i) That library has a mem.o object in it already (highly unlikely, but you can use MPLAB C18 tools to review the contents of that library), or

ii) Portions of mem.c are showing up in your main.c as well, and they are being compiled to provide duplicates of e.g. OScTcbP, a Salvo object.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Pic18 + C18 + OSDelay (major trouble)

Postby aek » Thu Jan 13, 2011 2:56 pm

Also, you should be doing Build All, not Make, when you have a problem like this.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Pic18 + C18 + OSDelay (major trouble)

Postby Daani4all » Thu Jan 13, 2011 3:12 pm

-DMAKE_WITH_FREE_LIB -DSYSE appears automatically when I add "MAKE_WITH_FREE_LIB" in project options,
If I understood the book right I should copy the mem.c from my salvo folder into my project folder and include it right?
then I #include it in the main file togheter with salvo.h. I also have my salvocgf.h added.
Then I add the library search path: salvo\lib\mcc18 and MCC18\lib
Linker Script Search path: MCC18\bin\LKR and include search path salvo\inc

at last I create a main.c and this is what it looks like:

Code: Select all
#pragma config OSC = INTIO67, FCMEN = OFF, IESO = OFF, PWRT = OFF, BOREN = SBORDIS, BORV = 3, WDT = OFF
#pragma config WDTPS = 32768, MODE = MC, ADDRBW = ADDR20BIT, DATABW = DATA16BIT, WAIT = OFF, CCP2MX = PORTC
#pragma config ECCPMX = PORTE, LPT1OSC = OFF, MCLRE = ON, STVREN = ON, LVP = OFF, BBSIZ = BB2K, XINST = OFF


#include <salvo.h>
#include "mem.c"
#undef OSC
#include <p18f8722.h>
#include <stdio.h>



void main( void )
{



      OSInit();
   
      
}



not much? so I cant see why Im having so much trouble. I have reinstalled it several times and always ends up here?
Daani4all
 
Posts: 14
Joined: Wed Dec 01, 2010 4:29 pm

Re: Pic18 + C18 + OSDelay (major trouble)

Postby aek » Thu Jan 13, 2011 3:49 pm

Daani4all wrote:-DMAKE_WITH_FREE_LIB -DSYSE appears automatically when I add "MAKE_WITH_FREE_LIB" in project options


Get Rid of MAKE_WITH_FREE_LIB. And SYSE. Why do I have to repeat myself? They are only for use with a Pumpkin-sourced salvocfg.h. They no longer exist in Salvo 4, because they caused so much confusion. They were used (only) in Salvo v3 examples.


If I understood the book right I should copy the mem.c from my salvo folder into my project folder and include it right?


Nowhere* in ANY Salvo documentation does it say to copy ANY Salvo file to any other place. The only place for Salvo files is in their install directories.

(*: Except with pathetic versions of Eclipse)


then I #include it in the main file togheter with salvo.h. I also have my salvocgf.h added.


Nowhere in ANY Salvo documentation does it say to include anything but salvo.h in your files.

Then I add the library search path: salvo\lib\mcc18 and MCC18\lib
Linker Script Search path: MCC18\bin\LKR and include search path salvo\inc


Correct.

at last I create a main.c and this is what it looks like:

Code: Select all
#pragma config OSC = INTIO67, FCMEN = OFF, IESO = OFF, PWRT = OFF, BOREN = SBORDIS, BORV = 3, WDT = OFF
#pragma config WDTPS = 32768, MODE = MC, ADDRBW = ADDR20BIT, DATABW = DATA16BIT, WAIT = OFF, CCP2MX = PORTC
#pragma config ECCPMX = PORTE, LPT1OSC = OFF, MCLRE = ON, STVREN = ON, LVP = OFF, BBSIZ = BB2K, XINST = OFF


#include <salvo.h>
#include "mem.c" //aek  ABSOLUTELY NOT!
#undef OSC
#include <p18f8722.h>
#include <stdio.h>



void main( void )
{



      OSInit();
   
      
}



not much? so I cant see why Im having so much trouble. I have reinstalled it several times and always ends up here?


You keep up ending here because you're doing things that are never suggested in the Salvo docs. Remove #include "mem.c" From your main. You will never find #include *.c anywhere* in Salvo docs, because it is not correct. Only header files should be included, and the only header file you need for Salvo is salvo.h.

(*: OK, there are some highly optimized examples that include salvo source code like timer.c instead of linking to it, but that's only for use in severely stack-restricted processors like the PIC12. It is not pretty C, and should be avoided, and is not necessary with the PIC18.)
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Pic18 + C18 + OSDelay (major trouble)

Postby Daani4all » Fri Jan 14, 2011 12:54 pm

Thanks a lot, really appreciate it. Now I dont get any errors :D thanks a thousand times.

I don't know yet but maybe you do, when I am debugging my "project" (just having a counter in one task and finalval variable in the other task)
But when I come to OSInit(); during the debug a "dissembly listing" pops out wich I never get out of during the stepping, it seems like its infinite. therefore I dont actually know if the task is being entered at all since the counter isnt counting at all? any clue?

it goes through the dissasembly listing once and then It ends up here aall the time
50: OSSched();
00794 EC0A CALL 0x14, 0
and goes through the entire code under sched.c and then it starts all over over and over again?

code:


Code: Select all
#include <salvo.h>
#include <p18f8722.h>
#include <stdio.h>
#include "portmap.h"
#include "Init.h"
#include "lcd.h"
#undef OSC



_OSLabel(Count_Task1)
_OSLabel(Display_Task1)

unsigned char counter = 0;
unsigned char finalval = 0;

void Count_Task( void )
{
   for(;;)
   {
      counter++;
      OS_Yield(Count_Task1);
   }
}

void Display_Task( void )
{
   for(;;)
   {
   finalval = counter<<5;
   OS_Yield(Display_Task1);
   }
}

void main( void )
{
   OSInit();
   OSCreateTask(Count_Task, OSTCBP(1), 10);
   OSCreateTask(Display_Task, OSTCBP(2), 10);
   for(;;)
   OSSched();
}

Daani4all
 
Posts: 14
Joined: Wed Dec 01, 2010 4:29 pm

Re: Pic18 + C18 + OSDelay (major trouble)

Postby aek » Fri Jan 14, 2011 5:27 pm

Disable the watchdog timer in your configuration bits.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Pic18 + C18 + OSDelay (major trouble)

Postby Daani4all » Fri Jan 14, 2011 5:30 pm

#pragma config OSC = INTIO67, FCMEN = OFF, IESO = OFF, PWRT = OFF, BOREN = SBORDIS, BORV = 3, WDT = OFF
#pragma config WDTPS = 32768, MODE = MC, ADDRBW = ADDR20BIT, DATABW = DATA16BIT, WAIT = OFF, CCP2MX = PORTC
#pragma config ECCPMX = PORTE, LPT1OSC = OFF, MCLRE = ON, STVREN = ON, LVP = OFF, BBSIZ = BB2K, XINST = OFF


I think it is , WDT = OFF?

salvocfg.h =>
Code: Select all
#define OSUSE_LIBRARY            TRUE
#define OSLIBRARY_TYPE            OSF
#define OSLIBRARY_GLOBALS         OSF
#define OSLIBRARY_CONFIG         OSA
#define OSEVENTS                    2 
#define OSEVENT_FLAGS               0
#define OSMESSAGE_QUEUES            0
#define OSTASKS                     2


My entire Main.c =>

Code: Select all
#pragma config OSC = INTIO67, FCMEN = OFF, IESO = OFF, PWRT = OFF, BOREN = SBORDIS, BORV = 3, WDT = OFF
#pragma config WDTPS = 32768, MODE = MC, ADDRBW = ADDR20BIT, DATABW = DATA16BIT, WAIT = OFF, CCP2MX = PORTC
#pragma config ECCPMX = PORTE, LPT1OSC = OFF, MCLRE = ON, STVREN = ON, LVP = OFF, BBSIZ = BB2K, XINST = OFF



#include <salvo.h>
#include <p18f8722.h>
#include <stdio.h>
#include "portmap.h"
#include "Init.h"
#include "lcd.h"
#undef OSC


void Count_Task(void);
void Display_Task(void);

_OSLabel(Count_Task1)
_OSLabel(Display_Task1)

unsigned int counter = 0;
unsigned int finalval = 0;

void Count_Task( void )
{
   for(;;)
   {
      counter = counter + 1;
      OS_Yield(Count_Task1);
   }
}

void Display_Task( void )
{
   for(;;)
   {
   finalval = counter;
   OS_Yield(Display_Task1);
   }
}

void main( void )
{
   OSInit();
   OSCreateTask(Count_Task, OSTCBP(1), 9);
   OSCreateTask(Display_Task, OSTCBP(2), 10);

   while(1)
   {
   OSSched();
   }
}







Daani4all
 
Posts: 14
Joined: Wed Dec 01, 2010 4:29 pm

Re: Pic18 + C18 + OSDelay (major trouble)

Postby Daani4all » Mon Jan 17, 2011 3:56 pm

is this a problem anyone ever have had?
Daani4all
 
Posts: 14
Joined: Wed Dec 01, 2010 4:29 pm

Previous

Return to PICmicro MCUs

Who is online

Users browsing this forum: No registered users and 3 guests

cron