help me pleas,I need a c compiler for this code :

Support for Bloader and Screamer

Moderator: phalanx

help me pleas,I need a c compiler for this code :

Postby yonas » Wed May 21, 2008 11:34 pm

Hi there,i am doing my final project but i found difficulty on the c compiler .
I need a c compiler for this code so,that i can find the HEX file.


/******************************************************************************\
* *
* P R E P R O C E S S O R D I R E C T I V E S *
* *
\******************************************************************************/
#include <16F877A.h>

#device *=16 ADC=10 // Use 16-bit pointers, use 10-bit ADC

#use delay(clock=20000000)

#use fast_io(A)
#use fast_io(B)
#use fast_io(C)

int8 errorCCond;
int8 zeroCond;
int8 oneCond;
int8 twoCond;
int8 threeCond;
int8 fourCond;
int8 fiveCond;
int16 tempVal;

// End Preprocessor Directives

#include "Include\Compiler.h"
#include "Include\Globals.h"
#include "Include\Misc.c"

/******************************************************************************\
* *
* F U N C T I O N P R O T O T Y P E S *
* *
\******************************************************************************/

void initTimers( void);
void initADC( void);
void timer1ISR( void);
void timer2ISR( void); // ISR does not stand for Illinois Street Residence

/******************************************************************************\
* *
* M A I N R O U T I N E *
* *
\******************************************************************************/
#pragma zero_ram // Interesting command ....
void main( void)
{
disable_interrupts(GLOBAL); // We don't want to be interrupted yet

delay_ms(500); // wait for voltages to stablize

Set_Tris_A(MY_TRISA); // Port A's I/O
Set_Tris_B(MY_TRISB); // Port B's I/O
Set_Tris_C(MY_TRISC); // Port C's I/O

delay_ms(50);

initTimers(); // This is where the interrupts are enabled again

delay_ms(50);

initADC();

while(FOREVER)
{
readADC_1();
}
}
// End Main Routine


/******************************************************************************\
* *
* S U B - R O U T I N E I M P L E N T A T I O N S *
* *
\******************************************************************************/


// Purpose: Initializes timer interrupts
// Precondition: None
// Postcondition: Timers and interrupts are enabled
void initTimers(void)
{
setup_timer_1( T1_INTERNAL | T1_DIV_BY_8 ); // confusing?
setup_timer_2( T2_DIV_BY_4, 0x20, 2); // even more so!
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
timer1Count = 0;
timer2Count = 0;
}


// Purpose: Initializes ADC
// Precondition: None
// Postcondition: ADC is configured
void initADC(void)
{
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel( 0 );
delay_us(10);
}

//End Sub-Routine Implementions

/******************************************************************************\
* *
* I N T E R R U P T S E R V I C E R O U T I N E S *
* *
\******************************************************************************/

// Purpose: Timer1 ISR
// Precondition: initTimers called
// Postcondition: Timer1 counter updated
#INT_TIMER1
void Timer1ISR(void)
{
timer1Count++;
timer2Count++;
}

#INT_TIMER2
void Timer2ISR(void)
{
if (timer1Count == 0)
{
if (((ADC_1 * 10) < 1013) || ((ADC_1 * 10) > 2058))
{
errorCCond = 1;
zeroCond = 0;
oneCond = 0;
twoCond = 0;
threeCond = 0;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 0
else if (((ADC_1 * 10) > 1013) && ((ADC_1 * 10) < 1218))
{
tempVal = 1013;
errorCCond = 0;
zeroCond = 1;
oneCond = 0;
twoCond = 0;
threeCond = 0;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 1
else if (((ADC_1 * 10) > 1218) && ((ADC_1 * 10) < 1423))
{
tempVal = 1218;
errorCCond = 0;
zeroCond = 0;
oneCond = 1;
twoCond = 0;
threeCond = 0;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 2
else if (((ADC_1 * 10)> 1423) && ((ADC_1 * 10) < 1628))
{
tempVal = 1423;
errorCCond = 0;
zeroCond = 0;
oneCond = 0;
twoCond = 1;
threeCond = 0;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 3
else if (((ADC_1 * 10) > 1628) && ((ADC_1 * 10) < 1832))
{
tempVal = 1628;
errorCCond = 0;
zeroCond = 0;
oneCond = 0;
twoCond = 0;
threeCond = 1;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 4
else if (((ADC_1 * 10) > 1832) && ((ADC_1 * 10) < 2037))
{
tempVal = 1832;
errorCCond = 0;
zeroCond = 0;
oneCond = 0;
twoCond = 0;
threeCond = 0;
fourCond = 1;
fiveCond = 0;
}
//displayC -> 5
else if (((ADC_1 * 10) > 2037) && ((ADC_1 * 10) < 2058))
{
errorCCond = 0;
zeroCond = 0;
oneCond = 0;
twoCond = 0;
threeCond = 0;
fourCond = 0;
fiveCond = 1;
}
}
else if ((timer1Count > 0) && (timer1Count < 230)) //display the output of pin D
{
//displayC -> EE
if (errorCCond == 1)
{
output_high (PIN_B0);
output_low (PIN_B1);
output_low (PIN_B2);
output_high (PIN_B3);
output_high (PIN_B4);
output_high (PIN_B5);
output_high (PIN_B6);
}
//displayC -> 0
else if (zeroCond == 1)
{
output_high (PIN_B0);
output_high (PIN_B1);
output_high (PIN_B2);
output_high (PIN_B3);
output_high (PIN_B4);
output_high (PIN_B5);
output_low (PIN_B6);
}
//displayC -> 1
else if (oneCond == 1)
{
output_low (PIN_B0);
output_high (PIN_B1);
output_high (PIN_B2);
output_low (PIN_B3);
output_low (PIN_B4);
output_low (PIN_B5);
output_low (PIN_B6);
}
//displayC -> 2
else if (twoCond == 1)
{
output_high (PIN_B0);
output_high (PIN_B1);
output_low (PIN_B2);
output_high (PIN_B3);
output_high (PIN_B4);
output_low (PIN_B5);
output_high (PIN_B6);
}
//displayC -> 3
else if (threeCond == 1)
{
output_high (PIN_B0);
output_high (PIN_B1);
output_high (PIN_B2);
output_high (PIN_B3);
output_low (PIN_B4);
output_low (PIN_B5);
output_high (PIN_B6);
}
//displayC -> 4
else if (fourCond == 1)
{
output_low (PIN_B0);
output_high (PIN_B1);
output_high (PIN_B2);
output_low (PIN_B3);
output_low (PIN_B4);
output_high (PIN_B5);
output_high (PIN_B6);
}
//displayC -> 5
else if (fiveCond == 1)
{
output_high (PIN_B0);
output_low (PIN_B1);
output_high (PIN_B2);
output_high (PIN_B3);
output_low (PIN_B4);
output_high (PIN_B5);
output_high (PIN_B6);
}
}
else if (timer1Count == 230)
{
timer1Count = 0;
//enable_interrupts(GLOBAL);
}

if (timer2Count == 0)
{
if (((ADC_1 * 10) < 1013) || ((ADC_1 * 10) > 2058))
{
errorCCond = 1;
zeroCond = 0;
oneCond = 0;
twoCond = 0;
threeCond = 0;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 0
else if (((ADC_1 * 10) > 1013) && ((ADC_1 * 10) < 1218))
{
tempVal = 1013;
errorCCond = 0;
zeroCond = 1;
oneCond = 0;
twoCond = 0;
threeCond = 0;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 1
else if (((ADC_1 * 10) > 1218) && ((ADC_1 * 10) < 1423))
{
tempVal = 1218;
errorCCond = 0;
zeroCond = 0;
oneCond = 1;
twoCond = 0;
threeCond = 0;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 2
else if (((ADC_1 * 10)> 1423) && ((ADC_1 * 10) < 1628))
{
tempVal = 1423;
errorCCond = 0;
zeroCond = 0;
oneCond = 0;
twoCond = 1;
threeCond = 0;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 3
else if (((ADC_1 * 10) > 1628) && ((ADC_1 * 10) < 1832))
{
tempVal = 1628;
errorCCond = 0;
zeroCond = 0;
oneCond = 0;
twoCond = 0;
threeCond = 1;
fourCond = 0;
fiveCond = 0;
}
//displayC -> 4
else if (((ADC_1 * 10) > 1832) && ((ADC_1 * 10) < 2037))
{
tempVal = 1832;
errorCCond = 0;
zeroCond = 0;
oneCond = 0;
twoCond = 0;
threeCond = 0;
fourCond = 1;
fiveCond = 0;
}
//displayC -> 5
else if (((ADC_1 * 10) > 2037) && ((ADC_1 * 10) < 2058))
{
errorCCond = 0;
zeroCond = 0;
oneCond = 0;
twoCond = 0;
threeCond = 0;
fourCond = 0;
fiveCond = 1;
}
}
else if ((timer2Count > 0) && (timer2Count < 230))
{
if (errorCCond == 1)
{
output_high (PIN_C0);
output_low (PIN_C1);
output_low (PIN_C2);
output_high (PIN_C3);
output_high (PIN_C4);
output_high (PIN_C5);
output_high (PIN_C6);
}
else if (fiveCond == 1)
{
output_high (PIN_C0);
output_high (PIN_C1);
output_high (PIN_C2);
output_high (PIN_C3);
output_high (PIN_C4);
output_high (PIN_C5);
output_low (PIN_C6);
}
else if (fiveCond != 1)
{
if (((ADC_1 * 10) - tempVal) < 20)// displayD -> 0
{
output_high (PIN_C0);
output_high (PIN_C1);
output_high (PIN_C2);
output_high (PIN_C3);
output_high (PIN_C4);
output_high (PIN_C5);
output_low (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 20) && (((ADC_1 * 10) - tempVal) < 40))//displayD -> 1
{
output_low (PIN_C0);
output_high (PIN_C1);
output_high (PIN_C2);
output_low (PIN_C3);
output_low (PIN_C4);
output_low (PIN_C5);
output_low (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 40) && (((ADC_1 * 10) - tempVal) < 61))//displayD -> 2
{
output_high (PIN_C0);
output_high (PIN_C1);
output_low (PIN_C2);
output_high (PIN_C3);
output_high (PIN_C4);
output_low (PIN_C5);
output_high (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 61) && (((ADC_1 * 10) - tempVal) < 81)) //display ->3
{
output_high (PIN_C0);
output_high (PIN_C1);
output_high (PIN_C2);
output_high (PIN_C3);
output_low (PIN_C4);
output_low (PIN_C5);
output_high (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 81) && (((ADC_1 * 10) - tempVal) < 102))//display ->4
{
output_low (PIN_C0);
output_high (PIN_C1);
output_high (PIN_C2);
output_low (PIN_C3);
output_low (PIN_C4);
output_high (PIN_C5);
output_high (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 102) && (((ADC_1 * 10) - tempVal) < 122))//display ->5
{
output_high (PIN_C0);
output_low (PIN_C1);
output_high (PIN_C2);
output_high (PIN_C3);
output_low (PIN_C4);
output_high (PIN_C5);
output_high (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 122) && (((ADC_1 * 10) - tempVal) < 143))//display ->6
{
output_low (PIN_C0);
output_low (PIN_C1);
output_high (PIN_C2);
output_high (PIN_C3);
output_high (PIN_C4);
output_high (PIN_C5);
output_high (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 143) && (((ADC_1 * 10) - tempVal) < 163))//display ->7
{
output_high (PIN_C0);
output_high (PIN_C1);
output_high (PIN_C2);
output_low (PIN_C3);
output_low (PIN_C4);
output_low (PIN_C5);
output_low (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 163) && (((ADC_1 * 10) - tempVal) < 184))//display ->8
{
output_high (PIN_C0);
output_high (PIN_C1);
output_high (PIN_C2);
output_high (PIN_C3);
output_high (PIN_C4);
output_high (PIN_C5);
output_high (PIN_C6);
}
else if ((((ADC_1 * 10) - tempVal) > 184) && (((ADC_1 * 10) - tempVal) < 204))//display ->9
{
output_high (PIN_C0);
output_high (PIN_C1);
output_high (PIN_C2);
output_low (PIN_C3);
output_low (PIN_C4);
output_high (PIN_C5);
output_high (PIN_C6);
}
}
}
else if (timer2Count == 230)
{
timer2Count = 0;
}
}
yonas
 
Posts: 1
Joined: Wed May 21, 2008 11:22 pm

Postby polly » Tue Jun 03, 2008 11:04 am

Maybe this guy can help:

Power Monitoring Project
By
Kevin Repple

ECE 445, SENIOR DESIGN PROJECT
SPRING 2006

TA: Ishaan Gupta
Date: 05/01/2006
<=>
polly
 
Posts: 190
Joined: Mon Jun 05, 2006 2:10 pm

Postby silic0re » Tue Jun 03, 2008 12:30 pm

That's really funny and terrible at the same time...

Are you the TA, or the student who wrote it in the first place?
silic0re
 
Posts: 349
Joined: Wed Apr 26, 2006 5:35 pm

Postby Philba » Tue Jun 03, 2008 12:41 pm

I'd say it doesn't really matter - busted!

It is a real shame that people feel like they can just rip off someones code and turn it in as their own. I sure hope the guy who designs AEDs or air traffic controller systems or other life-safety equipment didn't cheat his way through school.

As long as we are at it, that is pretty hideous code. I think it could be collapsed into about 1/10 the number of lines.
Philba
 
Posts: 2503
Joined: Sun Feb 13, 2005 11:33 pm
Location: Seattle

Postby Polux rsv » Wed Jun 04, 2008 1:53 am

I hope the guy who wrote this code is not a programming student :lol:

Angelo
Polux rsv
 
Posts: 247
Joined: Wed Oct 11, 2006 11:34 am
Location: Gland, Switzerland

Postby spikegomez » Fri Dec 19, 2008 11:57 pm

Yeah hope so....


_________________
A cool idea from Busby SEO Test
spikegomez
 
Posts: 1
Joined: Fri Nov 07, 2008 11:02 pm

Postby old_dave » Thu Jan 08, 2009 2:17 am

The compiler for that code looks to be CCS and can be found at www.ccsinfo.com
old_dave
 
Posts: 12
Joined: Mon Dec 29, 2008 6:35 pm

Postby kevinrepple » Sat Jul 18, 2009 5:09 pm

Polux rsv wrote:I hope the guy who wrote this code is not a programming student :lol:

Angelo

He's not.
kevinrepple
 
Posts: 1
Joined: Sat Jul 18, 2009 4:21 pm


Return to Boot Loading

Who is online

Users browsing this forum: No registered users and 1 guest