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

main functions?

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







main functions?
PostPosted: Tue Jun 09, 2009 5:43 am     Reply with quote

Hello,

I am pretty new to programming embedded circuits and was wondering if any one can help me? Apologies if this is a really stupid question as I am probably missing something quite obvious

I am building a datalogger that just asks a question and then stores the answer, however I am having some trouble with the main function.

The code I am using will compile fine but when running on the board will keep jumping back to the very beginning (and so initialise the lcd/ display welcome message) instead of to the beginning of the while loop. I have included a very simplified bit of my code as an example:
Code:

void main()
{
debounce();
lcd_init();
lcd_intro();
init_rtc();
         
while(TRUE)
  {   
   if (S1_pressed==TRUE)
      {
       multi_beep(2);
       test_question();      
      }
  }      
}

This code is meant to display a test question format when a button is pressed, however will always return to the very beginning of the main function.

I have tried messing around with the format loads (putting brackets left, right and centre) but am guessing I am missing something very obvious.

Any help or pointers would be much appreciated, cheers!
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Tue Jun 09, 2009 5:49 am     Reply with quote

You will proberbly find you have the WDT watch dog timer enabled which is resetting the pic because you are not kicking it.
If you post your fuse settings we could verify this.

Set NOWDT if you don't need it.
milner_86
Guest







main function?
PostPosted: Tue Jun 09, 2009 7:06 am     Reply with quote

Thank you so so much! That had been confusing me for days! You were right I had
Code:
#fuses hs, wdt, noprotect,  put, nobrownout,

now
Code:
#fuses hs, nowdt, noprotect,  put, nobrownout,

I never even thought to check that as I didn't really know what it meant (as I said complete novice). Is working fine now Smile Cheers
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