SK40C Beginner

nazfar WROTE:It is because your compiler does not recognize the library of "system.h" for your MC. Based on my experience, i am using PIC16F877A and using the library as same as you do but after I removed the library, it worksand my program working as I expected. I think it is because of your MC do not have such library to call. I hope it helps you
__CONFIG(HS & // External Crystal at High Speed
WDTDIS & // Disable Watchdog Timer.
PWRTEN & // Enable Power Up Timer.
BORDIS & // Disable Brown Out Reset.
MCLREN & // MCLR function is enabled
LVPDIS); // Disable Low Voltage Programming.
__CONFIG(FOSC_HS & // High Speed Crystal.
WDTE_OFF & // Disable Watchdog Timer.
PWRTE_ON & // Enable Power Up Timer.
BOREN_OFF & // Disable Brown Out Reset.
MCLREN_ON & // Enable MCLR
LVP_OFF); // Disable Low Voltage Programming.
#include <pic.h>
__CONFIG ( 0x3F32 );
#define LED_1 RC3
#define LED_2 RC2
#define LED_3 RA0
void init(void);
void delay(unsigned long data);
void main(void)
{
init();
for(int i=0;i<3;i++)
{
LED_1=1;
LED_2=0;
delay(100000);
LED_1=0;
LED_2=1;
delay(100000);
LED_1=0;
LED_2=0;
LED_3=1;
delay(100000);
LED_1=0;
LED_2=1;
LED_3=0;
delay(100000);
}
for(int j=0;j<3;j++)
(
LED_1 =1;
LED_2=1;
LED_3=1;
delay(100000);
}
void init()
{
TRISA=0b00000000;
TRISB=0b00000000;
TRISC=0b00000000;
TRISD=0b00000000;
TRISE=0b00000000;
}
void delay(unsigned long data) //delay function, the delay time
{
for( ;data>0;data-=1); //depend on the given value
}
for(int j=0;j<3;j++)
(
LED_1 =1;
LED_2=1;
LED_3=1;
delay(100000);
}
ober WROTE:OK, there are several reasons and you have solved some of the problem. I think earlier, you did not open the project file, and you create the project yourself without adding the system.h into project window. That is normal mistake.
Now, you can compile but you got this:
![]()
This is due to different version of Hi-tech compiler. We do not know why Hi-Tech change the label when they upgrade to different version. The sample code in tutorials is being compiled using Hi-Tech C compiler v9.80. You are using v9.83.
Try replace this:__CONFIG(HS & // External Crystal at High Speed
WDTDIS & // Disable Watchdog Timer.
PWRTEN & // Enable Power Up Timer.
BORDIS & // Disable Brown Out Reset.
MCLREN & // MCLR function is enabled
LVPDIS); // Disable Low Voltage Programming.
with this:__CONFIG(FOSC_HS & // High Speed Crystal.
WDTE_OFF & // Disable Watchdog Timer.
PWRTE_ON & // Enable Power Up Timer.
BOREN_OFF & // Disable Brown Out Reset.
MCLREN_ON & // Enable MCLR
LVP_OFF); // Disable Low Voltage Programming.
in the c code. Compile again, it should solve the problem, at least this problem