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

How to add a NOP at 0x000?

 
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 add a NOP at 0x000?
PostPosted: Thu Feb 11, 2016 11:55 am     Reply with quote

I make a research a month ago here and found a post where is explained how to add a NOP at 0x000 but I'm not able to find it now.

As far I remember it was to lines one that tell to the compiler that the code must start at 0x002 and also the reset vector.
the second line insert the NOP itself, something like

Code:
#ROM 0x0000=0xFFFF

_________________
Electric Blue
jeremiah



Joined: 20 Jul 2010
Posts: 1334

View user's profile Send private message

PostPosted: Thu Feb 11, 2016 12:10 pm     Reply with quote

The #build directive handles moving the reset vector (and interrupt vector table). You'll have to do that before the #ROM will work.
temtronic



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

View user's profile Send private message

PostPosted: Thu Feb 11, 2016 12:23 pm     Reply with quote

I have to ask why you need to do this ?


Jay
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Thu Feb 11, 2016 12:25 pm     Reply with quote

I found the post!

https://www.ccsinfo.com/forum/viewtopic.php?p=54131

and the code that make the trick is...

Code:

// Tell compiler to put reset code at address 0x0002,
// instead of at 0x0000, as is normally done.
#build(reset=0x0002)
#ROM 0 = {0xFFFF}     // Insert NOP at address 0

_________________
Electric Blue
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Thu Feb 11, 2016 12:28 pm     Reply with quote

temtronic wrote:
I have to ask why you need to do this ?


Jay


Some chips have a silicon bug that unexpectedly reset the PIC in certain conditions, and because I'm have some troubles with unexpected resets I adding this code in order to discard that possibility.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19436

View user's profile Send private message

PostPosted: Thu Feb 11, 2016 1:41 pm     Reply with quote

CCS will automatically add that fix for chips that are affected. In the device editor you can turn the fixes for particular errata on and off.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Feb 11, 2016 1:48 pm     Reply with quote

so you are proposing making the reset vector 4 byte space look like THIS??
0: NOP
1: NOP
2,3: GOTO <main>

OMG - i suppose this will work with ZEROS on 16f/18f but what on earth is
it supposed o FIX????????


Last edited by asmboy on Thu Feb 11, 2016 1:54 pm; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19436

View user's profile Send private message

PostPosted: Thu Feb 11, 2016 1:54 pm     Reply with quote

There was about one model of one processor perhaps 10 years ago, that gave a problem if there wasn't a NOP there. It was only one revision.

What puzzles me, is that the post he points to, explains exactly how to apply the fix. So why the question?.
Ttelmah



Joined: 11 Mar 2010
Posts: 19436

View user's profile Send private message

PostPosted: Thu Feb 11, 2016 3:43 pm     Reply with quote

As I said, this fix is automatically done for you.

If you create a project using the 6720, and compile it, you will see at the top of the list file:

Code:

*
00000:  NOP   
00002:  GOTO   0006
.................... #include <main6720.h

Went back 5 years, and all the compilers do it.

When that post was made, the 6720 A4, was new out, and the fix had only just been published. Unless using a ten year old compiler, or somebody has turned the fix off, there is no need to do this.

In the device editor, it is 'put NOP at 0000', and is ticked for this chip.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Fri Feb 12, 2016 7:05 am     Reply with quote

Ttelmah wrote:
CCS will automatically add that fix for chips that are affected. In the device editor you can turn the fixes for particular errata on and off.


I didn't know that.

Quote:
What puzzles me, is that the post he points to, explains exactly how to apply the fix. So why the question?.


Who are you talking to?
_________________
Electric Blue
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