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

saving reg on interrupt

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



Joined: 12 Nov 2012
Posts: 349
Location: South Africa

View user's profile Send private message

saving reg on interrupt
PostPosted: Tue Jul 10, 2018 8:00 am     Reply with quote

CCS 5.076
dsPIC33EP128GM604

If I look at the lst file for a program it seems that the compiler only saves W0 register (but uses both W0 and W4 in the handler). I have some strange behavior on the program where sometimes it would not setup the ADC correctly (which use W4 as the scratch reg) if I have the communication running when initializing the program.
Probably not a good idea, but anyway.

Here are the listing for the #int_rda
Code:
                         .................... // Purpose:    Interrupt service routine for handling incoming RS485 data 
                         .................... #int_rda
                         .................... void incoming_rs485() {
*
0022C F80042         PUSH    42             : PUSH SR to TOS
0022E F80036         PUSH    36             : PUSH RCOUNT to TOS
00230 F80054         PUSH    54             : PUSH TBLPAG to TOS
00232 781F80         MOV     W0,[W15++]     : Push W0 to TOS
00234 200020         MOV     #2,W0          : W0 = 2
00236 09000C         REPEAT  #C             : Repeat next instruction (C + 1) times
00238 781FB0         MOV     [W0++],[W15++] : Push [W0++] to TOS

Am I missing something regarding the saving of registers?
Very difficult to test this, as it will happen 1 in 100 times.

Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Tue Jul 10, 2018 8:16 am     Reply with quote

Code:

00236 09000C         REPEAT  #C             : Repeat next instruction (C + 1) times
00238 781FB0         MOV     [W0++],[W15++] : Push [W0++] to TOS


This pushes the data from address 2, 4, 6, 8, 0xA, 0xC etc. in RAM onto the stack, repeating 12 times. This is W1, W2, W3, W4, W5, W6, W7, W8, W9, W10, W11, W12
alan



Joined: 12 Nov 2012
Posts: 349
Location: South Africa

View user's profile Send private message

PostPosted: Tue Jul 10, 2018 8:21 am     Reply with quote

Thank you Ttelmah, missed that and that clear the register saving up for me.
So back to the drawing board to try and find an evasive fault.

Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Tue Jul 10, 2018 9:08 am     Reply with quote

Have fun.....

Funnily it is one of my 'pet peeves', that CCS insists on saving everything, when it doesn't need to. However it is the safe way to work!.

As a comment you have looked at the errata for your chip. There are a _lot_. If you are running at anything like full speed the clock related ones might apply. The horrible one on subsequent reads might also apply. If you are using a debugger the PTG ones will also apply.

When the erratum sheet is longer than the instruction list, you have to worry.... :(
TedKri



Joined: 13 Jul 2018
Posts: 1

View user's profile Send private message

PostPosted: Fri Jul 20, 2018 6:12 am     Reply with quote

Ttelmah wrote:
Have fun.....

Funnily it is one of my 'pet peeves', that CCS insists on saving everything, when it doesn't need to. However it is the safe way to work!.

As a comment you have looked at Privacy Pursuits for your chip. There are a _lot_. If you are running at anything like full speed the clock related ones might apply. The horrible one on subsequent reads might also apply. If you are using a debugger the PTG ones will also apply.

When the erratum sheet is longer than the instruction list, you have to worry.... :(


This is exactly what happened to me, the erratum was almost literally longer than the instruction list. It was a mess...
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