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

What's wrong?

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



Joined: 27 Aug 2014
Posts: 14

View user's profile Send private message

What's wrong?
PostPosted: Thu Sep 04, 2014 12:32 am     Reply with quote

Hello,

I successfully compiled the following prg but but couldn't run it. Do you think I should include the config bits?
Code:

#include <18f452.h>     
#FUSES XT,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT,NOOSCSEN,NOSTVREN,NODEBUG,NOWRT,NOWRTD,NOWRTB,NOWRTC,NOCPD,NOCPB,NOEBTR,NOEBTRB

#use delay (clock=4000000)

#define R_CZ   pin_b0
#define S_CZ   pin_b1
#define T_CZ   pin_b2

#define R_tetY    pin_e2
#define R_tetY_   pin_c1
#define S_tetY    pin_c3
#define S_tetY_   pin_c4
#define T_tetY    pin_c5
#define T_tetY_   pin_e0

//#use fast_io(b) //

int1 R=0;
int1 S=0;
int1 T=0;
int1 a=0;
int R1d=0;
int R2d=0;
int S1d=0;
int S2d=0;
int T1d=0;
int T2d=0;
int delay=100;

//****************** Timer0 *****************************
#int_timer0 
void  timer0_kesme ()   
{
    set_timer0(254);   
   
    //////////////////////////////////////////////////
    if (R1d)
    {
      R1d--;
      if (R1d==0)
         output_low(R_tetY);
    }
    if (R2d)
    {
      R2d--;
      if (R2d==0)
         output_low(R_tetY_);
    }
    ///
    if (S1d)
    {
      S1d--;
      if (S1d==0)
         output_low(S_tetY);
    }
    if (S2d)
    {
      S2d--;
      if (S2d==0)
         output_low(S_tetY_);
    }
    ///
    if (T1d)
    {
      T1d--;
      if (T1d==0)
         output_low(T_tetY);
    }
    if (T2d)
    {
      T2d--;
      if (T2d==0)
         output_low(T_tetY_);
    }
    //////////////////////////////////////////////////
       
    a = input(R_CZ);
   
    if (R!=a)
    {
      if (a)
      {
         output_high(R_tetY);
         R1d=delay;
      }
      else
      {
         output_high(R_tetY_);
         R2d=delay;
      }
      R=a;
    }
    ////
    a = input(S_CZ);
   
    if (S!=a)
    {
      if (a)
      {
         output_high(S_tetY);
         S1d=delay;
      }
      else
      {
         output_high(S_tetY_);
         S2d=delay;
      }
      S=a;
    }
    ////
    a = input(T_CZ);
   
    if (T!=a)
    {
      if (a)
      {
         output_high(T_tetY);
         T1d=delay;
      }
      else
      {
         output_high(T_tetY_);
         T2d=delay;
      }
      T=a;
    }   
}



void main ( )
{
   setup_psp(PSP_DISABLED);       
   setup_spi(SPI_SS_DISABLED);   
   setup_timer_1(T1_DISABLED);     
   setup_timer_2(T2_DISABLED,0,1);
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);             
   setup_CCP1(CCP_OFF);           
   setup_CCP2(CCP_OFF);           


   setup_timer_0(RTCC_INTERNAL | RTCC_DIV_4);
   set_timer0(254);   

   enable_interrupts(INT_timer0);
   enable_interrupts(GLOBAL);   
   
   output_low(R_tetY);
   output_low(R_tetY_);
   output_low(S_tetY);
   output_low(S_tetY_);
   output_low(T_tetY);
   output_low(T_tetY_);

   while(1)   
   {
   
   }

 }
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 2:55 am     Reply with quote

A few questions.

1) Compiler version?
2) Real hardware or Proteus/ISIS.
3) How are your switches wired?
4) What do you expect to happen?
5) Can you get a simple LED flasher to work at the correct speed?

Mike
theredkid



Joined: 27 Aug 2014
Posts: 14

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 3:16 am     Reply with quote

1) CCS C MPLAB IDE v8.92
2) Real Hardware
3) PIC KIT 3
4) This is a PIC software to control 3 phase thyristor triggering.
5) No LED flash.
temtronic



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

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 7:17 am     Reply with quote

crawl before you run !!

first confirm that you can flash the LEDs with a simple program like the 1Hz LED test.

A simple toggle LED, delay 1/2 second, repeat.

recode/recompile/retest/report back if that is successful !

jay
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 7:20 am     Reply with quote

1) That is NOT your CCS C Compiler version. Spend some time on the forum to learn what this question *really* means.
2) Please post a picture of your hardware
3) Your reply has nothing to do with the question asked
4) This is now your third thread on this topic.
5) Learn to test your basic hardware by performing a simple LED flashing program. Your program is really silly!
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 8:04 am     Reply with quote

PLEASE put in meaningful subjects.

I can't stress how subtly important this is.

If you can't take the time to do so, why should anyone take the time to look at your problem?
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
theredkid



Joined: 27 Aug 2014
Posts: 14

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 9:34 am     Reply with quote

ezflyr wrote:
1) That is NOT your CCS C Compiler version. Spend some time on the forum to learn what this question *really* means.
2) Please post a picture of your hardware
3) Your reply has nothing to do with the question asked
4) This is now your third thread on this topic.
5) Learn to test your basic hardware by performing a simple LED flashing program. Your program is really silly!




- How come you know my prg is silly? It's for controlling 3 phase thyristor triggering sequence. If u think my prg is silly, then u r supposed to know a smarter version. Would you mind share it here?
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 10:57 am     Reply with quote

Hi,

Frankly, it's hard to know where to start!

Right now, you say 'No LED flash', but do you even know that your PIC is running, and running at the correct frequency? You need to create a simple test program that does nothing else except toggle a single LED at a known frequency. Turn the LED On for one second, and then Off for one second. Do this in a loop with delays, do not use timers! This has been covered many, many times before. Your program is currently not working at all, so you need to drastically simplify it to test the basics first!

Your variable names are really bad! Come on, can't you come up with nothing more descriptive than 'R', 'S', and 'T', etc.? A lack of descriptive variable names leads to code like this:

Code:

 if (T!=a)
    {
      if (a)
      {


which is virtually unreadable code. While trying to understand your code I found myself getting dizzy with my eyes crossing......

Your code structure is really poor! This has been covered many, many times, and I think mentioned to you in one of your other threads, you want to keep your interrupt handlers as short as possible, and do all your processing in Main(). Use the interrupt handler to set a flag, change a variable, etc. and then do everything else in Main().

Finally, your code has zero comments. You come here asking for our help, and then expect us to wade thru a maze of cryptic, undocumented code??

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 11:08 am     Reply with quote

Your board schematic that you posted here,
http://oi57.tinypic.com/2mxfm7r.jpg
is missing the 22 pf capacitors on the crystal. Nothing is going to work
until you fix that.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

What's wrong
PostPosted: Thu Sep 04, 2014 1:41 pm     Reply with quote

I'm in a good mood, so I'll settle for almost everything.

Mike
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