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

LED flashing problem

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



Joined: 08 Aug 2005
Posts: 22

View user's profile Send private message

LED flashing problem
PostPosted: Wed Oct 19, 2005 6:27 am     Reply with quote

Hi there

I am new to using the CCS compiler. I was trying to flash an LED just as a test program but the LED doesnt flash. My code is as below:
Code:


#include "C:\Documents and Settings\Atmadarshini dd\My Documents\trial.h"
  #include <stdio.h>
  #include <stddef.h>
  #include <stdlib.h>
  #include <string.h>
#int_RDA
#define MCLR PIN_B1
#define DATA_OUT PIN_B2
#define DATA_IN PIN_B4
#define CLOCK PIN_B5

RDA_isr() {

}



void main() {

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_CLOCK_DIV_2);
   setup_spi(FALSE);
   setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   enable_interrupts(INT_RDA);
   enable_interrupts(global);


   for(;;)
   {
   output_low(CLOCK);
   delay_ms(200);
   output_high(CLOCK);
   delay_ms(200);

   }


}


could someone tell me what i am doing wrong asap.

Thanks
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

Re: LED flashing problem
PostPosted: Wed Oct 19, 2005 7:44 am     Reply with quote

Atma wrote:
#include "C:\Documents and Settings\Atmadarshini dd\My Documents\trial.h"
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#int_RDA
#define MCLR PIN_B1
#define DATA_OUT PIN_B2
#define DATA_IN PIN_B4
#define CLOCK PIN_B5
// I'm going to comment this out, as you should
//RDA_isr() { // NEVER leave an empty interrupt handler!!!!

//}



void main() {

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
// since you're not using the RDA interrupt, DON'T enable it unless you
// have a proper handler for it!!!
//enable_interrupts(INT_RDA);
//enable_interrupts(global);


//for(;;) I'm going to replace this for loop with something more "standard"
while (TRUE)
{
output_low(CLOCK);
delay_ms(200);
output_high(CLOCK);
delay_ms(200);

}


}
[/code]


Try it with the changes above.
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 19, 2005 7:56 am     Reply with quote

You forgot to add
Code:
#use delay(clock=....)

_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Oct 19, 2005 8:14 am     Reply with quote

Code:

#include <16F877.h>   //  Change according with your uC
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000) // change according with the Xtal you are using

void main()
{
while(1)
  {
   output_toggle(PIN_B5);
   delay_ms(200);
  }
}



Humberto


Last edited by Humberto on Wed Oct 19, 2005 10:12 am; edited 1 time in total
Atma



Joined: 08 Aug 2005
Posts: 22

View user's profile Send private message

Re: LED flashing problem
PostPosted: Wed Oct 19, 2005 8:17 am     Reply with quote

newguy wrote:
Atma wrote:
#include "C:\Documents and Settings\Atmadarshini dd\My Documents\trial.h"
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#int_RDA
#define MCLR PIN_B1
#define DATA_OUT PIN_B2
#define DATA_IN PIN_B4
#define CLOCK PIN_B5
// I'm going to comment this out, as you should
//RDA_isr() { // NEVER leave an empty interrupt handler!!!!

//}

Hi i tried it...It didnt work

I have a 1K resistor that is connected to pin RB5 and the resistor goes to LED and the LED is connected to 5V(the postive side of the LED).

The same circuit works when use the cc5x compiler.



void main() {

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
// since you're not using the RDA interrupt, DON'T enable it unless you
// have a proper handler for it!!!
//enable_interrupts(INT_RDA);
//enable_interrupts(global);


//for(;;) I'm going to replace this for loop with something more "standard"
while (TRUE)
{
output_low(CLOCK);
delay_ms(200);
output_high(CLOCK);
delay_ms(200);

}


}
[/code]


Try it with the changes above.
Atma



Joined: 08 Aug 2005
Posts: 22

View user's profile Send private message

PostPosted: Wed Oct 19, 2005 8:19 am     Reply with quote

asmallri wrote:
You forgot to add
Code:
#use delay(clock=....)


hi this is added in the .h file. so i presume that it gets added to the project.
Atma



Joined: 08 Aug 2005
Posts: 22

View user's profile Send private message

PostPosted: Wed Oct 19, 2005 8:22 am     Reply with quote

Humberto wrote:
Code:

#include <16F877.h>   //  Change according with your uC
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000) // change according with the Xtal you are using

void main()
{
while(1)
  {
   output_toggle(PIN_B5);
   delay_ms(500);
  }
}



Humberto


hi

it says undefined output_toggle when i se your code above
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Oct 19, 2005 8:37 am     Reply with quote

Quote:

it says undefined output_toggle when i se your code above


Output_toggle can be replaced by:

Code:


while(1)
  {
   output_high(CLOCK);
   delay_ms(200);
   output_low(CLOCK);
   delay_ms(200);
  }
 


You would know that in your inquire you must include:

1) Compiler version. (3.xxx format)
2) Full header.
3) Short and concise hardware description.

Keep well,

Humberto
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