.: EMICROS :.  Embedded Micro Software
Home CAN232 CANUSB I2C232 I2CUSB CanWiser Learn C
Add your text here
Contact

Email : info@emicros.com

Ordering Information

.: Ordering using our PayPal powered shopping cart (PayPal account not required).

CAN232 : $79
CANUSB : $89
I2C232 : $79

I2CUSB : $89

Click here to View Cart and check out.

 

 

 

 
The program on the right shows how this is done. Note that basically we just added more 1's to the port setting statement (as well as changed from PORTC to PORTB).

Nothing real earth shattering hear but what happened to the delay functions we just introduced?

What we'd like to look at now is reusing the delay functions by putting them in a separate file so we can share the functions with other programs.

The second line in the program is another #include statement but it's different from the first one. The first one has the include file name in brackets <> which tells the compiler to find it in one of it's standard search directories. The 2nd line has the file name in double quotes which tells the compiler that it should find it stored with the project.

 

#include <htc.h>
#include "delay.h"
//------------------------------------
// file: led4_1.c
// description: This is the C code
// for the 4 LED project
// author: Emicros
//------------------------------------
/*------------------------------------
** function: TimerISR
** description: This is just a place
** holder for now and isn't used in
** the program.
**----------------------------------*/
void interrupt TimerISR( void )
{
   if( (TMR1IE) && (TMR1IF) )
   {
      TMR1IF = 0;
   }
}
/*-----------------------------------
** function: main()
** description: Main function.
**----------------------------------*/
void main( void )
{
   TRISB = 0b00001111;
   TRISC = 0b11111011;
   while( 1 )
   {
        /* turn on the 4 leds */
      PORTB = 0b11110000;
      PORTC = 0b00000100;
           delay_ms( 50 );
           /* turn off the 4 leds */
      PORTB = 0b00000000;
      PORTC = 0b00000000;
          delay_ms( 50 );
   }
}

 
 
Copyright 2010 Embedded Micro Software. All rights reserved