Page 1 of 9

SK40C Beginner

PostPosted: Tue Jan 31, 2012 8:09 pm
by vick5821
Hey guys, I have just got my SK40C today!!! Damn excited.However, I do not know how to start ? I downloaded the code from cytron tutorial websites but it build failed in MPLAB IDE..

how to solve it ?

This is the error msg :(

Image

Re: SK40C Beginner

PostPosted: Tue Jan 31, 2012 8:59 pm
by robosang
Printscreen the whole MPLAB IDE, show us the project window.

Re: SK40C Beginner

PostPosted: Wed Feb 01, 2012 3:01 pm
by nazfar
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 works ;) and 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 ;)

Re: SK40C Beginner

PostPosted: Wed Feb 01, 2012 3:48 pm
by vick5821

Re: SK40C Beginner

PostPosted: Wed Feb 01, 2012 3:49 pm
by vick5821
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 works ;) and 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 ;)

Then what should I do ?

Re: SK40C Beginner

PostPosted: Wed Feb 01, 2012 6:45 pm
by ober

Re: SK40C Beginner

PostPosted: Wed Feb 01, 2012 9:20 pm
by robosang
Ober, you are right, I have that problem too. Why is HI-TECH changing it? Really not convenience to us. I have to change all my old code accordingly. Worst, they also change some of the register name, such as ADGO become AD_GODONE. :o

Re: SK40C Beginner

PostPosted: Wed Feb 01, 2012 10:29 pm
by vick5821
CODE: SELECT_ALL_CODE
#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
}

This is my code, and this is how it operate..Weird working based on code right? anyone can tell me why ?

http://www.youtube.com/watch?v=egRCZTx3 ... e=youtu.be

Re: SK40C Beginner

PostPosted: Thu Feb 02, 2012 7:05 am
by ABSF
for(int j=0;j<3;j++)
(
LED_1 =1;
LED_2=1;
LED_3=1;
delay(100000);
}


If you are expecting the above code to flash the 3 LED for 3 times, you wont be able to get it. Think about it over carefully. The rest of the video matches your code.

Allen

Re: SK40C Beginner

PostPosted: Thu Feb 02, 2012 11:14 pm
by vick5821