CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

RTOS and CAN 18f2580

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Lemosek



Joined: 15 Oct 2011
Posts: 36

View user's profile Send private message

RTOS and CAN 18f2580
PostPosted: Tue Mar 20, 2012 11:09 am     Reply with quote

Hello, I have strange problem. I write a simple code:
Code:

#include <18F2580.h>
#fuses HS, NOPROTECT, PUT, BROWNOUT, NOWDT, NOLVP
#use delay(clock=20M)
#use rtos(timer=1,minor_cycle=20ms)
#include <can-18F4580.c>  // Use correct driver

#include "button.c"


//definicje ID CAN

#define BOARD_ID_LEDMATRIX 30
#define BOARD_ID_MAIN_LEDMATRIX 31



//*************** Global variables ****************

int8 sem;

struct rx_stat rxstat;
int32 rx_id;
int32 tx_id;
int8 rx_len;               
volatile int8 buffer_rcv[8];
int8 buffer_tx[8];




//*************************** TASK *****************************
#task(rate=200ms,max=20ms)
void Led_button_task ( );

#task(rate=1000ms,max=20ms)
void Button_task ( ); // odczyt stanu przycisków co 10ms



//======== button task =====//
void Button_task(){


    can_putd(BOARD_ID_MAIN_LEDMATRIX, buffer_tx, 1, 1, 1, 0);
 

}


void Led_button_task()
{




}


//======================================
void main()
{


//CAN
can_init();

  sem=1;
  rtos_run();

 

}


Compiler warning:
Warning 216 Interrupts disabled during call to prevent re- entrancy: (can_set_id)

Why I have this warning??

CCS PCH C Compiler, Version 4.128.

In past I write some code with CAN bus and RTOS for dsPIC30f6010A and I also use Can_putd function in tasks and don't have this warning.

Best regards
R.L.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 20, 2012 3:07 pm     Reply with quote

Both can_putd() and can_init() call the can_set_id() function.

I don't have the CCS RTOS, but apparently tasks are called from within
an interrupt routine.
Code:

void Button_task(){

    can_putd(BOARD_ID_MAIN_LEDMATRIX, buffer_tx, 1, 1, 1, 0);

}

That would explain why you get the "interrupts disabled" warning.
Quote:

In past I write some code with CAN bus and RTOS for dsPIC30f6010A and
I also use Can_putd function in tasks and don't have this warning.

I don't have the PCD compiler, but it's possible that it allows nested
interrupts and re-entrant routines. I have no experience with dsPICs
or PCD. But that could explain the difference. Or, it's also possible
that you had Warnings disabled when you used the PCD compiler.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group