View previous topic :: View next topic |
Author |
Message |
vladtess
Joined: 14 May 2011 Posts: 26
|
PIC12F629 Doesn't work as expected. |
Posted: Wed May 18, 2011 10:30 pm |
|
|
Hi fellas,
I am using 4.093 version of ccs. I have been working with 16F84A, but today decided to play with 12F629. Here is the simple code I am trying to run:
Code: | #include <12F629.H>
#fuses INTRC, BANDGAP_lOW, MCLR
#use delay (clock = 4000000)
void main() {
set_tris_a(0x0);
output_high(PIN_A3);
} |
For some reason PIC simulator doesn't get far, only 5 instructions ahead and doesn't seem to turn on the LED.
I am sure I am missing some directive or something. Please guide me if some one knows. Thanks much all!
PS. What us up with a bandgap? I've never had to deal with that in 16f84a. Thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
vladtess
Joined: 14 May 2011 Posts: 26
|
|
Posted: Wed May 18, 2011 11:04 pm |
|
|
I've copied your code into the compiler and added a pull up resistor. The thing is that the simulator still stops on the 5th instruction. I use PIC simulator IDE. Maybe I should use something else?
And as I said, I have a bandgap problems, programmer sometimes complaining that "The bandgap value of the pic is ... 0x03. Use value on buffer 0x00"
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 18, 2011 11:26 pm |
|
|
Quote: | I use PIC simulator IDE.
|
What is that ? Do you mean MPLAB simulator ? |
|
|
vladtess
Joined: 14 May 2011 Posts: 26
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 19, 2011 12:53 am |
|
|
Quote: | The thing is that the simulator still stops on the 5th instruction. |
The Oshonsoft simulator may not know that there is supposed to be
an OSCCAL value programmed at the last ROM address in the 12F629.
As a work-around, you can place a typical value at that address with
a #rom statement. Add the #rom line shown below to your program
(in that exact location). See if it now works.
Code: |
#include <12F629.h>
#fuses INTRC_IO, NOWDT, NOMCLR, PUT, BROWNOUT
#use delay(clock=4000000)
#rom 0x3FF = {0x3480}
//==========================
void main()
{
while(1)
{
output_high(PIN_A2);
delay_ms(500);
output_low(PIN_A2);
delay_ms(500);
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Thu May 19, 2011 2:34 am |
|
|
Add the caveat - use this for simulation only, don't write this to the chip (unless you have already destroyed the OSCCAL value). The value at this location is programmed 'at the factory'.
Best Wishes |
|
|
vladtess
Joined: 14 May 2011 Posts: 26
|
|
Posted: Thu May 19, 2011 9:16 am |
|
|
OK, thanks you guys I'll try this out when I get home! |
|
|
|