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

movf - Expecting an opcode mnemonic (WOAH!!!!)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 19, 2004 7:18 am     Reply with quote

Quote:
I could actually change it to
.
.
.
.
This is correct.
Quote:
Would I be correct in thinking that clear_interrupt is in newer versions of the compiler?

Correct again. I don't know when it was introduced, but it definately is in v3.187. Check the readme file in your compiler directory for a description of all additions to the manual.
Humberto



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

View user's profile Send private message

PostPosted: Thu Aug 19, 2004 7:54 am     Reply with quote

Quote:

Would I be correct in thinking that clear_interrupt is in newer versions of the compiler?



3.184 A new built in function CLEAR_INTERRUPT has been added


Humberto
homfray



Joined: 19 Nov 2003
Posts: 45
Location: Oxford

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

You guys ARE THE DON
PostPosted: Thu Aug 19, 2004 7:58 am     Reply with quote

boys, due to all your help I have got some code that is absolutely flying along Want to say a massive thanks to all of you!!!!! I have only had a quick check on the code but it appears to be working a treat. Very Happy Very Happy CHEERS!!!!

Here is the code if anyone is interested. I am not sure if this is the most efficient way to write this as I am a one of those dreadful physicists that where never supposed to be programmers and just ended up doing it one day.

The code reads in portE and portF and compares it with the previous if it is different it stores it .

Code:
#define Fosc 40000000                 // I'm using a 40 MHz crystal
#include <18F8621.h>
//-------------------------------------------------------------------------------------
// COMPILER DIRECTIVES and HARDWARE CONFIGURATION
#use delay(clock = Fosc)

#fuses EC_IO
#fuses NOOSCSEN   // Oscillator System Clock Switch Disabled
#fuses NODEBUG   // No Background Debugger
#fuses NOLVP      // Low Voltage ICSP Disabled
#fuses NOPROTECT    // No Code Protect
#fuses NOWDT      // No onboard watchdog
#fuses PUT         // Power Up Timer Enabled
#fuses BROWNOUT   // Brown Out Reset enabled
#fuses WRT
#fuses STVREN

#bit TMR2IF=0x0F9E.1

//-------------------------------------------------------------------------------------
// GLOBALS - GENERAL
static short state = 0;    //State Switch for watchdog
int8 delay_in_us = 10;
int16 i, us;
int8 newE, oldE, newF, oldF, s;
int8 io1[700], io2[700], time2[700];
int16 time1[700];
//-------------------------------------------------------------------------------------
// FUNCTION PROTOTYPES - GENERAL
void setupMain(void);
//-------------------------------------------------------------------------------------
// MAIN
void main()
{
   setupMain();
   while (1)
    {

      //Wait for Timer_interrupt_flag
          while (! TMR2IF); 

          TMR2IF=0;

      newE=input_e();
      newF=input_f()& 0b011111111;

      if(newE != oldE || newF != oldF && i < 700 && s < 200)
      {
         io1[i]=newE;
         io2[i]=newF;
         time1[i]=us;
         time2[i]=s;
         i++;
      }   
      
      newE = oldE;
      newF = oldF;

      us++;

      if(us==10000)
      {
         us=0;
         s++;
      }

      output_bit(PIN_H0,state);   
      state=~state;
      }
}
//-------------------------------------------------------------------------------------
// MAIN SETUP
void setupMain(void)
{
      setup_timer_2(T2_DIV_BY_1, delay_in_us, 10);
     TMR2IF=0;
       disable_interrupts(GLOBAL);         // disable all interrupts

     oldE = input_e();
      oldF = input_f() & 0b011111111;

      us=0;
      s=0;
      i=0;
}

_________________
Nice!!!
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 19, 2004 10:41 am     Reply with quote

Thanks for sharing your code! Always nice to hear someone is happy and willing to share the results of their efforts.

Just two more remarks.

Remark 1:
A bug. You never change the values for oldE and oldF.
Code:
      newE = oldE;
      newF = oldF;

should be replaced by
Code:
      oldE = newE;
      oldF = newF;


Remark 2:
Looking at the compiled code I see 111 instructions in the while loop. As a rough estimation your loop will execute in 11us, this is longer than the current timer2 delay of 10us. I suggest you either increase the timer2 delay to 15us, or optimize the loop.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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