View previous topic :: View next topic |
Author |
Message |
Orimga Guest
|
Reset question |
Posted: Thu Apr 03, 2008 6:05 pm |
|
|
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
|
|
Posted: Thu Apr 03, 2008 6:15 pm |
|
|
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
|
|
Posted: Thu Apr 03, 2008 6:23 pm |
|
|
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
|
|
Posted: Thu Apr 03, 2008 6:56 pm |
|
|
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
|
|
Posted: Fri Apr 04, 2008 1:45 am |
|
|
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
|
|
Posted: Fri Apr 04, 2008 7:14 am |
|
|
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
|
|
Posted: Fri Apr 04, 2008 7:53 am |
|
|
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. |
|
|
|