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

Pic 24FJ instruction DISI

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



Joined: 21 Sep 2021
Posts: 3
Location: Vancouver, Canada

View user's profile Send private message

Pic 24FJ instruction DISI
PostPosted: Tue Sep 21, 2021 5:18 pm     Reply with quote

Is there a built-in function in picc-d that sets and uses the DISI instruction for this processor family?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19505

View user's profile Send private message

PostPosted: Wed Sep 22, 2021 1:35 am     Reply with quote

It is used throughout the generated code, but to generate it yourself, you
would simply have to use assembler.
It would be almost impossible to use inside normal C code, since you do not
have any ability to know how many instructions a C code line actually uses.
So like this:
Code:

#define DISI10() {#ASM \
   DISI #10 \
   #ENDASM}

//generates a Macro 'DISI10', which inserts a DISI #10 instruction when
//used.

   DISI10();


But you will have t count the instructions you need it for, and adapt the
macro to suit.
temtronic



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

View user's profile Send private message

PostPosted: Wed Sep 22, 2021 4:57 am     Reply with quote

OK, curious am I,
Why would you need to use it ?
I had a quick read and it only disables some interrupts(based on 'level') and ONLY for a finite time( 16383 machine cycles), so the 'time' isn't fixed...change the CPU speed and the DISI time changes as well.
I'd think the CCS supplied functions would work for 99.44% of all applications ??
rogerp2



Joined: 21 Sep 2021
Posts: 3
Location: Vancouver, Canada

View user's profile Send private message

PostPosted: Wed Sep 22, 2021 11:30 am     Reply with quote

Hi Ttelmah

Thanks. Whereas I agree it is difficult to determine how many cycles a chunk of C code uses (read the .lst file), there is another way:

#asm
disi #16383
#endasm
C code to be protected
#asm
disi #0
#endasm

That does work.

Roger Pryor
rogerp2



Joined: 21 Sep 2021
Posts: 3
Location: Vancouver, Canada

View user's profile Send private message

PostPosted: Wed Sep 22, 2021 11:34 am     Reply with quote

Hi temtronic

Curiosity solved - The short answer is that I'm mucking about with interrupts and code functions used both in ISR and the main line. This instruction is actually very powerful when trying to avoid lockups. The long answer is much longer and not of general interest.

Thanks anyway

Roger Pryor
Ttelmah



Joined: 11 Mar 2010
Posts: 19505

View user's profile Send private message

PostPosted: Wed Sep 22, 2021 12:00 pm     Reply with quote

If you are fiddling around doing it twice, then just use a standard
disable_interrupts call. You do understand that you can specify what level
of disable is to be applied.
It is a pointless approach.
jeremiah



Joined: 20 Jul 2010
Posts: 1346

View user's profile Send private message

PostPosted: Wed Sep 22, 2021 12:37 pm     Reply with quote

rogerp2 wrote:
Hi Ttelmah

Thanks. Whereas I agree it is difficult to determine how many cycles a chunk of C code uses (read the .lst file), there is another way:

#asm
disi #16383
#endasm
C code to be protected
#asm
disi #0
#endasm

That does work.

Roger Pryor


If you are doing it that way, I would recommend just using
Code:

disable_interrupts(GLOBAL);
//code
enable_interrupts(GLOBAL);


For a more general solution that works in a lot more contexts you can use the critical section library:
https://www.ccsinfo.com/newsdesk_info.php?newsPath=ALL&newsdesk_id=213
Ttelmah



Joined: 11 Mar 2010
Posts: 19505

View user's profile Send private message

PostPosted: Wed Sep 22, 2021 11:23 pm     Reply with quote

Yes, I use this library for certain hardware transactions that have to be
'atomic'. Works well. There are a few little 'syntactical sneakies', that
have to be used if the flow through the code can have multiple paths,
but with a bit of care it is a very good way of working.
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