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.

My first Hi-Ttech C Programme

Status
Not open for further replies.

PA3040

Advanced Member level 3
Joined
Aug 1, 2011
Messages
883
Helped
43
Reputation
88
Reaction score
43
Trophy points
1,308
Activity points
6,936
Dear All
This is my first Hi-Tech C program with 16f877

This program working well but only fault is when delay value exceed 200 __delay_ms(200);

the program blink only one other wise blink forever



Code:
#include <htc.h>
#define _XTAL_FREQ 4000000 // 4 MHz clock 


//__CONFIG(CP_OFF  & BOREN_OFF & WDTE_OFF & PWRTE_ON & FOSC_XT );
 
__CONFIG(0X3F39);


 main(){

TRISC = 0;
//TRISD = 0;

while(1){

PORTC = 0xff;
__delay_ms(150);

PORTC = 0x00;
__delay_ms(150);


}


}

Thanks
Please advice
 

Check the data type for the delay argument.
If it is a unsigned char, max value is 255.
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Hi btbass
Thanks for reply
can you please explain how may I change the delay argument
Thanks in advance
 

you need to look at the code for the delay function, and then if it is an unsigned char, change it to an unsigned int,
max value 65535.
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Hi btbass
I am new fo c
can you please where the delay function is located
Thanks in advance
 

What Hi-Tech version you use? If use latest version 9.83, there is no problem up to 1000.
But, you still have solution, you can do for loop
ex: for(i=0;i<1000;i++) __delay_ms(1);
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top