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

Reset question

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







Reset question
PostPosted: Thu Apr 03, 2008 6:05 pm     Reply with quote

Hi,

Can anyone tell me why the code starts on the "while(true)" rotine when i reset the PIC instead the top of main function?

Thanks
Guest_7068
Guest







PostPosted: Thu Apr 03, 2008 6:15 pm     Reply with quote

When the PIC is reset, the program counter gets set to 0x0000. The compiler has a goto statement located at 0x0000 that takes you to main.

How do you know that it is reaching the while(true) without going to main? Are you doing anything before while(true) that does not happen after reset?
Ormiga
Guest







PostPosted: Thu Apr 03, 2008 6:23 pm     Reply with quote

yes, i'm initializing an LCD and write a value. When i turn on the circuit everything work's fine, but when i reset the circuit seems like the pointer stay the same. I also simulate the circuit in proteus vsm, and same error occurred. Can i forgetting something on he code?

thanks
Guest_7068
Guest







PostPosted: Thu Apr 03, 2008 6:56 pm     Reply with quote

It has to do with your initialization code. If you are not able to display anything, then check your driver - See if any tris bits need to be set (hardware issue)
Check all variable and make sure they are initialized.
Matro
Guest







PostPosted: Fri Apr 04, 2008 1:45 am     Reply with quote

If it's a hardware reset, all registers will be initialized.
But if you talk about the reset_cpu() function, what's happening is normal if you use a PIC16. reset_cpu() is a software reset and in the PIC16 case, it just set the PC to 0x0000 nut doesn't reset the registers.

What reset are you talking about (hardware or software)?
Which chip are you using?

Matro.
Ormiga
Guest







PostPosted: Fri Apr 04, 2008 7:14 am     Reply with quote

Hi Matro,
I'm using a PIC18F2550, and i'm reseting by hardware. I also simulated the circuit in Proteus, and watching the registers, the system entered in a endless loop, and do not run my program. I'm using #FUSES MCLR. Actualy in the real cicuit, the only thing that makes me belive the program runs ffrom while(true) function, is the CCP1 PWM, that do not mean anything, because the register is not set to zero. At end, i think that the real circuit is also entering in a endless loop. Can anyone help me?

Thanks
Matro
Guest







PostPosted: Fri Apr 04, 2008 7:53 am     Reply with quote

So a good thing could be that you post a simplified code with all preprocessor directives and initializations.
Are you sure that your hardware reset is performed correctly, i.e. that the MCU is really resetted?

Matro.
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