Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

helping on Unknown c copiler

Status
Not open for further replies.

alaalwi11

Member level 1
Joined
Nov 30, 2010
Messages
32
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Al khurtum-Sudan
Activity points
1,626
hi friend, ihave got some available project from some webside
i know that the code was writeen in c language but i can not know the compiler
can one hlp me


code:
HTML:
/*****************************
*	Author: Chris @ PyroElectro.com
*	Date: 4/14/2011
*
*	Description:
*	The Pyro Propeller Clock POV detects a home location
*   via a high priority interrupt on INT0, falling edge and
*	starts outputing on PORTA and PORTC using the set_leds function
*   everytime a timer0 low priority interrupt is triggered.
*
******************************/

#include <p18f252.h>
#include <delays.h>
#include <timers.h>
#include <capture.h>

void InterruptHandlerLow (void);
void InterruptHandlerHigh (void);

void set_leds(unsigned long int);

#define LED_LATCH_H PORTBbits.RB4
#define LED_LATCH_L PORTBbits.RB5

unsigned long int led_count = 12;
unsigned int int_count=0;
unsigned int long led_all = 0x0000;

unsigned int clock[4] = {3,2,1,0};

unsigned int number_array[]={
//Number: 0
0b00000,	// *****
0b01110,	// *   *
0b01110,    // *   *
0b01110,	// *   *
0b00000,	// *****
//Number: 1
0b11111,
0b00000,
0b00000,	// *****
0b11111,
0b11111,
//Number: 2
0b01000,	// * ***
0b01000,	// * ***
0b01010,	// * * *
0b00010,	// *** *
0b00010,	// *** *
//Number: 3
0b01010,	// * * *
0b01010,	// * * *
0b01010,	// * * *
0b01010,	// * * *
0b00000,	// *****
//Number: 4
0b00011,	// ***
0b11011,	//   *
0b11011,	//   *
0b00000,	// *****
0b11011,	//   *
//Number: 5
0b00010,	// *** *
0b01010,	// * * *
0b01010,	// * * *
0b01010,	// * * *
0b01000,	// * ***
//Number: 6
0b00000,	// *****
0b01010,	// * * *
0b01010,	// * * *
0b01010,	// * * *	
0b01000,	// * ***
//Number: 7
0b01111,	// *     
0b01111,	// *     
0b01100,	// *  **     
0b01011,	// * *     
0b00111,	// **     
//Number: 8
0b00000,	// *****
0b01010,	// * * *
0b01010,	// * * *
0b01010,	// * * *
0b00000,	// *****
//Number: 9
0b00011,	// ***
0b01011,	// * *
0b01011,	// * *
0b01011,	// * *
0b00000,	// *****
//Letter :
0b11111,	//
0b10101,	//  * *
0b10101,	//  * *
0b11111,	//
0b11111,	//
};

void main(void){

unsigned long int i=0;

//PORTA All Digital Outputs
ADCON1 = 0b00000111;

//Setup Output/Inputs
TRISA = 0x00;
TRISB = 0x0F;
TRISC = 0x00;

PORTA = 0x00;
PORTB = 0x00;
PORTC = 0x00;


//Setup Interrupts
RCON = 0b10000000; 
INTCON = 0b11110000;
PIE1 = 0b00000000;

//TMR0 Interrupt Low-Priority
INTCON2bits.TMR0IP = 0;
INTCONbits.TMR0IE = 1;

//Clear LED Display
set_leds(0xFFFF);

OpenTimer0( TIMER_INT_ON & T0_16BIT & T0_SOURCE_INT & T0_PS_1_1 );
WriteTimer0( 0xF094 ); //0x3CAF );

while(1){
			Delay10KTCYx(100);
			//set_leds(0x0000); 

			//Clock Number Output Control

			if (clock[0] == 9){
			clock[0] = 0;
				if(clock[1] == 5){
				clock[1] = 0;
					if(clock[2] == 2){
					clock[2] = 0;
						if(clock[3] == 1){
							clock[3] = 0;
						}
						else
							clock[3]++;
					}
					else
						clock[2]++;
				}
				else
					clock[1]++;
			}
			else
				clock[0]++;

}

}

void set_leds(unsigned long int leds){

PORTA = 0x0F;
PORTC = 0xF0;

LED_LATCH_L = 1;
LED_LATCH_L = 0;

PORTA = leds & 0x0F;
PORTC = leds & 0xF0;

LED_LATCH_H = 1;
LED_LATCH_H = 0;

}

//INTERRUPT CONTROL
#pragma code InterruptVectorHigh = 0x08		//interrupt pointer address (0x18 low priority)
void InterruptVectorHigh (void)
{
        _asm						//assembly code starts
        goto InterruptHandlerHigh	//interrupt control
        _endasm						//assembly code ends
}
#pragma code
#pragma interrupt InterruptHandlerHigh		//end interrupt control

//INTERRUPT CONTROL
#pragma code InterruptVectorLow = 0x18		//interrupt pointer address (0x18 low priority)
void InterruptVectorLow (void)
{
        _asm						//assembly code starts
        goto InterruptHandlerLow	//interrupt control
        _endasm						//assembly code ends
}
#pragma code
#pragma interrupt InterruptHandlerLow		//end interrupt control



void InterruptHandlerLow()
{

        if(INTCONbits.TMR0IF)		//check if TMR0 interrupt flag is set
        {
				WriteTimer0( 0xFE49 );  //Reset Timer0 for 20mS Delay
				if(led_count > 0)
					led_count--;

				//Set The Clock Numbers On Top					
				if(led_count < 0x11D && led_count > 0x117){
				set_leds(number_array[(led_count&0x07) + (clock[0]*5)]);
				}
				else if(led_count < 0x115 && led_count > 0x10F){
				set_leds(number_array[(led_count&0x07) + (clock[1]*5)]);
				}
				else if(led_count < 0x10D && led_count > 0x107){
				set_leds(number_array[(led_count&0x07) + 50]);
				}
				else if(led_count < 0x105 && led_count > 0xFF){
				set_leds(number_array[(led_count&0x07) + (clock[2]*5)]);
				}
				else if(led_count < 0xFD && led_count > 0xF7){
				set_leds(number_array[(led_count&0x07) + (clock[3]*5)]);
				}
				else{
				set_leds(0xFFFF);
				}
			   INTCONbits.TMR0IF = 0;	//Clear TMR0 Flag              
        }
INTCONbits.GIEL = 1;						//Re-enable all interrupts
}

void InterruptHandlerHigh()
{
        if(INTCONbits.INT0IF)		//check if TMR0 interrupt flag is set
        {
			led_count = 325;
			WriteTimer0( 0xFFE0 );
			INTCONbits.TMR0IF = 0;	//Clear TMR0 Flag     
			INTCONbits.INT0IF = 0;
        }
INTCONbits.GIEH = 1;		
}
Best regards,

alaalwi11
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top