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 CCS Technical Support

How to separate math routines?

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



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

How to separate math routines?
PostPosted: Thu Aug 06, 2015 9:52 am     Reply with quote

There's any way to have separate math routines for INTs and Main code?
_________________
Electric Blue
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 06, 2015 10:01 am     Reply with quote

Not too sure what you mean, so please provide an example program that show us. The more you explain the easier and faster we can help.

Also, I'm assuming INTs means Interrupt Service Routines ?

Hmm, which 'math' routines ? If it's simple code, it'd be inline, complex then callable as it becomes more efficient in code space and time.

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 06, 2015 10:07 am     Reply with quote

See this thread and the links in it.
http://www.ccsinfo.com/forum/viewtopic.php?t=42118
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Thu Aug 06, 2015 12:07 pm     Reply with quote

@temtronic

I need to use 16bit division and multiplication inside interrupts and in the Main code.

@PCM programmer

I read an tried #org and compile, but the message

Interrupts disabled during call to prevent re-entrancy:

still appear.

I do something like

Code:

#include <18F67J50.h>
//Several variables definition
//.....
//.....

//.....

#include <Config.h>
#include <usb_cdc.h>
#include <stdlib.h>

// Includes all USB code and interrupts, as well as the CDC API
#include <string.h>
#include <strings2.h>
#include "25LC256.h"
#include "Bits_Rules.h"

//Few prototypes
//....
//....

#org 0x1FF, 0x8000
//Here start all the subroutines and functions that are called by different interrupt handlers

////Some 16 bit division and multiplication here

void CountData()// <---This routine is called from Main once at start and from one interrupt handler
{
//.......
//.......
}
#org DEFAULT
void Main (void)
{
//Some 16 bit division and multiplication here too
}


I tried to putt #org DEFAULT before CountData() too and get the same Warning.

So I think is not working, I don't end to understand how #org works.

What I'm doing wrong? Question
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Thu Aug 06, 2015 1:59 pm     Reply with quote

The USB code contains one 16bit multiplication. So it'll still give the error.

They accept it, since on a PIC18, it uses the hardware multiplier and is only a handful of instruction times.

So I'd not worry about multiplication, but division really should be avoided, just on the grounds of time.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Thu Aug 06, 2015 2:39 pm     Reply with quote

I'm not receiving warnings about math yet, I'm asking before implement it to know hot to proceed.

This are all the warning for the current version

>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (ReadByteEE)
>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (FillBufferEE)
>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (@PSTRINGC_1801)
>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (usb_token_reset)
>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (SaveTime)
>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (usb_cdc_flush_tx_buffer)
>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (usb_tbe)
>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (usb_cdc_get_discard)
>>> Warning 216 "GPRS_2.c" Line 11917(1,2): Interrupts disabled during call to prevent re-entrancy: (CountData)


ReadByteEE, FillBufferEE,,SaveTime and CountData are subroutines and functions maked by me, the rest are from CCS USB library.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Fri Aug 07, 2015 2:29 am     Reply with quote

Yes. These routines are basically 'initialisation'. So (for instance) the routine that clears the buffer is only called in the main code, when USB first wakes. Hence there is no loss really in having interrupts disabled during it. It's used in the interrupts when a bus reset has to take place. You can simply duplicate it if required, but it gains nothing to do so.

I'd worry about anything involving 'EE' in an interrupt though. Given the milliseconds most types of electrically erasable memory take, that has alarm bells ringing....
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