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

Odd behavior with PIC10F222

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



Joined: 27 Dec 2013
Posts: 69

View user's profile Send private message

Odd behavior with PIC10F222
PostPosted: Thu May 18, 2017 2:05 pm     Reply with quote

Hi All,

I have a super simple program that is giving me headaches. I am trying to pulse an output on and off at a particular rate. I eventually plan to do this with timer0, but for now I am using delay_ms functions to test the hardware.


main.h is as follows:
Code:
#include <10F222.h>
#device ADC=8 
#use delay(internal=8MHz)
#use timer(timer=0,tick=10ms,bits=8,NOISR)


main.c is as follows:
Code:
#include <main.h>

                   


void main()                       
{                                 

   unsigned int16 delayTime = 1000;

                                                   
                           
                             
   while(TRUE)                             
   {           


         output_high(PIN_B2);
         delay_ms(delayTime);     
         output_low(PIN_B2);       
         delay_ms(delayTime);     
                               
   }               
                                                               
}   


The code works well when I have the programmer supplying 5V to the board. If I attempt to run the PIC on battery power with the programmer removed, it will run for 20-30s and then stop. To get it to run again, I have to remove power, connect the programmer, turn on power, then remove the programmer.

I'm not really sure whats going on here. Heres the schematic, http://i.imgur.com/2sZvOeU.png

I have added a 4.9k pullup from GP3 to +5V.

Any ideas what might be going on here?

Thanks!
temtronic



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

View user's profile Send private message

PostPosted: Thu May 18, 2017 3:46 pm     Reply with quote

two 'problems'..that we need more information about....

1) NO fuses are in your program......

2) was the program compiled in 'debug' or 'realease' mode if using MPLAB ?
demedeiros



Joined: 27 Dec 2013
Posts: 69

View user's profile Send private message

PostPosted: Thu May 18, 2017 8:19 pm     Reply with quote

I built the project using the project wizard. I assumed this would automatically set the proper fuse settings... Guess not

I am using the ccs ide and not MPLAB.

Thank you!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 18, 2017 8:57 pm     Reply with quote

What's your compiler version ?

This thread explains how to put the CCS IDE into Debug or Release mode:
http://www.ccsinfo.com/forum/viewtopic.php?t=55756

The 10F222 doesn't have ICD capability, so it shouldn't be possible to
put it in Debug mode. But I have not used the CCS IDE.
Ttelmah



Joined: 11 Mar 2010
Posts: 19221

View user's profile Send private message

PostPosted: Fri May 19, 2017 12:59 am     Reply with quote

The 10F222, does support ICD. The core has this feature, and they do a 'repackaged' version with extra pins so it can be sensibly used. However the feature is present on all the chips.

Unlike MPLAB, it shouldn't be possible to 'accidentally' select ICD. However it could be happening....

One other obvious thing is that when the programmer is attached, you have a ground connection from the programmer. Double check where the ground goes when this is not connected.
temtronic



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

View user's profile Send private message

PostPosted: Fri May 19, 2017 5:11 am     Reply with quote

re: project wizard...
NEVER 'assume' any Wizard or simulator sets a PIC up the way YOU 'think' it should be !!

There's been hundreds of posts here where 'it doesn't work' ended up being how the PIC was setup/configured by a wizard or simulator software.

Personally I prefer the PIC to have all I/O default to digital use, as it was ...in the beginning...nowdays with all the peripherals on pins (ADC, comps, timers, sio, etc) you NEED to carefully read and confirm how the 'other guy' setup the PIC !

Jay
demedeiros



Joined: 27 Dec 2013
Posts: 69

View user's profile Send private message

PostPosted: Fri May 19, 2017 7:15 am     Reply with quote

Compiler version is 5.065

I have tried to determine if the IDE is in debug or release mode, but I cant seem to figure that out. The debugger is certainly not enabled in the IDE, however I do not see a clear way to disable the debugger.

Interestingly, if I use CCSLOAD and use the built hex file, the code does not execute. If I program through the IDE using "Build & Run" or "Program" it does execute.
newguy



Joined: 24 Jun 2004
Posts: 1902

View user's profile Send private message

PostPosted: Fri May 19, 2017 8:16 am     Reply with quote

I've found that sometimes the processor needs to have power cycled after it is programmed, otherwise it won't run/execute. Depends on the type of programmer, and also something I've only seen with dsPICs. Can you try cycling the power after programming with the setup that didn't run to see if it then runs?
demedeiros



Joined: 27 Dec 2013
Posts: 69

View user's profile Send private message

PostPosted: Fri May 19, 2017 8:22 am     Reply with quote

Figured it out... fuses.

If I manually set the fuses:

Code:
#fuses IOSC8,MCPU,NOWDT   


The program runs as written.

Never had any problems in the past, but I will be sure to keep an eye on fuses from now on!

Thanks to everyone for your help!
Ttelmah



Joined: 11 Mar 2010
Posts: 19221

View user's profile Send private message

PostPosted: Fri May 19, 2017 8:32 am     Reply with quote

I had just started to say you need to set your fuses, and then saw you had posted. You will see that Temtronic pointed this out in the first reply.

Fuses do not 'default'. They go to the erased state unless you set them, and the erased state will often not be what you want....
jeremiah



Joined: 20 Jul 2010
Posts: 1317

View user's profile Send private message

PostPosted: Fri May 19, 2017 9:02 am     Reply with quote

demedeiros wrote:
Compiler version is 5.065

I have tried to determine if the IDE is in debug or release mode, but I cant seem to figure that out. The debugger is certainly not enabled in the IDE, however I do not see a clear way to disable the debugger.

Interestingly, if I use CCSLOAD and use the built hex file, the code does not execute. If I program through the IDE using "Build & Run" or "Program" it does execute.


As a note, if using CCSLoad, make sure that after you program the device that you tell it to Run. CCSLoad does not automatically do that and will hold the device in reset state until you press the Run button.
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