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

programmed chip does nothing

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







programmed chip does nothing
PostPosted: Sun Nov 21, 2004 10:34 pm     Reply with quote

okay so i programmed a simply program that was supposed to set pinb0 high for 100ms and then take it low for 100ms and i get nothing on the scope. i used the wizard to start the project and defined pin b0 as output but i didnt check the box that said to use pullups on portB. it compiled fine and i know the chip is powered and wired correctly as i have gotten a program to work the lcd a little. the program that works was written and compiled with mplab and not ccs.

it seems like even when i compile the program and put it on the chip it doesnt run. if i dont terminate the program it will go back to the top and run the program over and over nonstop right?

what could be wrong.
matt
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sun Nov 21, 2004 10:39 pm     Reply with quote

Quote:
what could be wrong.


All sorts of things. Try posting the code!
lucky



Joined: 12 Sep 2003
Posts: 46
Location: South Coast - England

View user's profile Send private message Visit poster's website

programmed chip does nothing
PostPosted: Mon Nov 22, 2004 7:01 am     Reply with quote

Quote:
if i dont terminate the program it will go back to the top and run the program over and over nonstop right?


The Compiler will add a Sleep(); to the end of your code. Put your code in a loop:

Code:

while(TRUE){
     output_high(PIN_B0);
     delay_ms(100);
     output_low(PIN_B0);
     delay_ms(100);

_________________
Lucky
www.mpic3.com - MPIC3 player project, Forum, Downloads, Online Shop
buckeyes1997
Guest







thanks
PostPosted: Mon Nov 22, 2004 9:01 am     Reply with quote

yes that is exactly the code i used minus the while statement. i thought about adding that but didnt get to it yet. my thought was maybe it is working but stops so quick i never see it on the scope.

ill try that and see.
buckeyes1997
Guest







i think i need the while statement.
PostPosted: Mon Nov 22, 2004 5:24 pm     Reply with quote

is there a way to strip the sleep statement before writing to the chip???

Code:
  #include <ctype.h>
  #include <stdio.h>
  #include <stddef.h>
  #include <stdlib.h>
  #include <string.h>


void main()
{

   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);

   delay_ms(100);
   output_high(PIN_B0);
   delay_ms(100);
   output_low(PIN_B0);


}
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Mon Nov 22, 2004 5:40 pm     Reply with quote

No. You need the while(1); statement.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 22, 2004 5:45 pm     Reply with quote

You still won't see much. The point of a test program is
to make it obvious that things are working. This is best
done with a loop and longer delays. Examples:
http://www.ccsinfo.com/forum/viewtopic.php?t=19199
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 22, 2004 6:32 pm     Reply with quote

To spell it out for you

Code:

void main()
{

   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);

  while(1)
  {
    delay_ms(100);
    output_high(PIN_B0);
    delay_ms(100);
    output_low(PIN_B0);
  }
}
buckeyes1997
Guest







thanks
PostPosted: Mon Nov 22, 2004 6:49 pm     Reply with quote

hey guys ill try that. i thought about using the toggle function but wanted to do it explicitly.

what time delay should i use to make it show up on the scope more clearly?? i think i should easily be able to observe the 100ms on the scope shouldnt i?? i will try it and report my findings.

thanks
matt
buckeyes1997
Guest







hey it works
PostPosted: Tue Nov 23, 2004 6:57 pm     Reply with quote

hey i was able to verify that the pin toggles on the scope. all i had to do was put the while statement in there to keep it out of sleep. why on earth did they put an invisible sleep command in there.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Nov 23, 2004 7:33 pm     Reply with quote

So it would run off into space and then start over.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

Re: hey it works
PostPosted: Wed Nov 24, 2004 8:52 am     Reply with quote

buckeyes1997 wrote:
hey i was able to verify that the pin toggles on the scope. all i had to do was put the while statement in there to keep it out of sleep. why on earth did they put an invisible sleep command in there.


There is no "operating system" to return to as you would have on a DOS/WINDOWS/UNIX/LINUX box.

Writing C code for a microcontroller is not quite like writing for "big iron" and you are ultimately responsible for providing the microcontroller everything it needs, including how to keep it from falling off the edge of the world when your program ends.

A suggestion, if this is your first time working with a microcontroller, I suggest you try writing a few small, simple programs with MPASM (free from Microchip's web site) and get a feel for that before writing much more C code. You don't have to write a file server or TCP/IP stack in assembly, just blink some leds and maybe try using one of the on-chip perpherials like one of the timers and also debounce a pushbutton switch. Knowing how to do that in assembly will really help you later when you are teasing out a problem in C and need to look at the LST file.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
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