Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Timeout waited for PIC

Status
Not open for further replies.

msab2006

Newbie level 4
Joined
Nov 21, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
Hey everyone, I need some help here. I've so far writen the program as below and I've managed to get the hex file. I'm trying to download the program into a PIC18F452. FYI, I'm using a 40-pin enhanced start-up kit. When I try to download the file and click "start bootloader", the message " error :timeout waited for PIC" comes out. Any idea what I'm doing wrong? I really need some help here. Is it anything to do with the settings? I've set the flow rate to "software", but still no change.

//RE2 connects to Sensor
//RD1 connects to INPUT1 DRIVING MOTOR
//RD2 connects to INPUT2 DRIVING MOTOR
//RD3 connects to INPUT1 BRAKING MOTOR
//RD4 connects to INPUT2 BRAKING MOTOR
//RC2/CCP1 connects to EN1 (RMotor)
//RC1/CCP2 connects to EN1 (FMotor)

void initialize(void);
void drivingmotor(unsigned char);
void brakingmotor(unsigned char);

unsigned int fsensor;

void main(){
initialize(); //Call initialization function
PWM_Start(); //Start PWM for CCP1
CCP2CON = 0x3C; //Start PWM for CCP2

drivingmotor(256); //Forward with full speed
while(1) // Loop forever
{
fsensor = ADC_Read(1); // Sensor input value

if (fsensor > 1.30)
{
brakingmotor(256); //Braking at 100%
}

if (fsensor < 1.30 && fsensor > 0.68)
{
brakingmotor(192); //Braking at 75%
}

if (fsensor < 0.68 && fsensor > 0.55)
{
brakingmotor(128); //Braking at 50%
}

if (fsensor < 0.55 && fsensor > 0.44)
{
brakingmotor(64); //Braking at 25%
}
}

}




void initialize() { // Initialization function
PORTE = 0; // Set PORTE to low
TRISE = 255; // Set PORTE as input
ADCON1 =0x80; // Set AN0-AN7 to analog input
PORTD = 0; // Set PORTD to low
TRISD = 0; // Set PORTD as output
fsensor = ADC_Read(1); // Capture initial Sensor value
PWM_Init(5000); // Initialize PWM module with 5k frequency
CCP2CON = 0x30;
}

void drivingmotor(unsigned char speed) //Driving motor function
{
PWM_Change_Duty(speed); // Set motor speed
PORTD.F2 = 1; // Control IN1 MD1
PORTD.F1 = 0; // Control IN2 MD1
}

void brakingmotor(unsigned char speed) //Braking motor function
{
PWM_Change_Duty(speed); // Set motor speed
PORTD.F4 = 0; // Control IN1 MD1
PORTD.F3 = 1; // Control IN2 MD1
}


I hope someone can help me in this asap, really appreciate it. Thanks.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top