Kryten
New Member
Hi Im trying to compile this code
But i get this cgpic.exe has stopped working in windows. Is my code that "hard" to compile? or is my code just really wrong?
Thanks for all help
Code:
///////////////////////////////////////////////////////////////
// //
// Lights for bike trolly //
// Turn indicators and back - brake lights //
// //
///////////////////////////////////////////////////////////////
//#include <pic.h>
#include <htc.h>
#include <pic12f6x.h>
__CONFIG (UNPROTECT & MCLRDIS & PWRTDIS & WDTDIS & INTIO & BOREN);
//////////////////////////////////////////////////////////////
// Definitoins //
//////////////////////////////////////////////////////////////
#define _XTAL_FREQ 4000000
#define PORT_LED_LEFT (GPIO0)
#define PORT_LED_RIGHT (GPIO1)
#define PORT_LED_BRAKE (GPIO2)
#define PORT_BTN_LEFT (GPIO3)
#define PORT_BTN_RIGHT (GPIO4)
#define PORT_BTN_BRAKE (GPIO5)
#define DELAY (__delay_ms(125))
#define DELAY_BRAKE (__delay_ms(1))
///////////////////////////////////////////////////////
// Interrupt routine //
///////////////////////////////////////////////////////
#pragma interrupt_level 0
void interrupt ISR (void)
{
if(1 ==PORT_BTN_BRAKE )
{
PORT_LED_BRAKE = 1; //Brake light
}
else
{
PORT_LED_BRAKE = 0; // Brake light will flash, on 1 ms off 1 ms resulting in 50%
DELAY_BRAKE; // light emmison.
PORT_LED_BRAKE = 1;
DELAY_BRAKE;
}
}
/////////////////////////////////////////////////////////
// Main program routine //
/////////////////////////////////////////////////////////
void main (void)
{
GPIO = 0x00;
CMCON = 0x07;
TRISIO = 0b11111000; // GP0, GP1 and GP2 are outputs. GP3, GP4 and GP5 are inputs.
ei();
while (1)
{
if (1 == PORT_BTN_LEFT) // If left butten is pressed, left turn indicator will blink
{
PORT_LED_LEFT = 1;
DELAY;
DELAY;
DELAY;
PORT_LED_LEFT = 0;
DELAY;
DELAY;
DELAY;
}
else if ( 1 == PORT_BTN_RIGHT) // If right button is pressed, right turn indicator will blink
{
PORT_LED_RIGHT = 1;
DELAY;
DELAY;
DELAY;
PORT_LED_RIGHT = 0;
DELAY;
DELAY;
DELAY;
}
else
{
PORT_LED_LEFT = 0;
PORT_LED_RIGHT = 0;
}
}
}
But i get this cgpic.exe has stopped working in windows. Is my code that "hard" to compile? or is my code just really wrong?
Thanks for all help