Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Mikroc program problem

Status
Not open for further replies.

einton

New Member
hi guys hope everyone will be fine there ,guys i am doing my first program of mikroc which giving some problem
i m using pic18f452-I/P and 10 Mhz crystal the program is stated as which i think is right
void main()
{
unsigned char J = 1;
TRISB = 0;
for(;;) // Endless loop
{
PORTB = J; // Send J to PORTC
Delay_ms(1000); // Delay 1 second
J = J << 1; // Shift left J
if(J == 0) J = 1; // If last LED, move to first LED
}
}
THE PROGRAM IS ABOUT CHASING LEDS IM USING MIKROC PRO
i have tested all connection on my breadboard they are all fine, i have used following config setting
osc:HS
OSCS:DISABLED
PWRT: DISABLED
BOR:ENABLED
BORV:4.5
WDT:DISABLED
CCP2:MUX
STACK OV:DISABLED
LVP: DISABLED
BACK. DEBUG:DISABLED

I HAVE TRIED MANY CONFIG SETTING AND I THINK MY UNIVERSAL PROGRAMMER IS FINE AND I HAVE SUPPLIED RIGHT BITS.
I HAVE DONE ACCORDING TO MY BEST AND I DONT KNOW WHY MY LEDS ARE NOT WORKING.PLEASE TELL ME WHAT I CAN DO FURTHER WHAT DO U THINK I M MISSING AND WHATMORE I CAN TRY.
 
Last edited:

einton

New Member
yes my this program works with 4 Mhz crystal
void main()
{
TRISB = 0; // Configure PORTB as output
TRISC = 0;
TRISD = 0;
for(;;) // Endless loop
{
PORTB = 0XFF; // Turn ON LED
PORTC= 0XFF;
PORTD= 0XFF;
Delay_ms(5000); // 5 second delay
PORTB = 0; // Turn OFF LED
PORTD = 0;
PORTC = 0;
Delay_ms(5000); // 5 second delay
}
}
but guys this is not showing led blinking , i have try to increase deLAy upto 5 fold but nothing different im using HS CONFIG.
 

gaspode42

Member
Hi Einton

Are both these projects using the same processor 18F452?
 

gaspode42

Member
Try this:

Code:
void main() {
     TRISB = 0; // Configure PORTB as output
     TRISC = 0;
     TRISD = 0;
     while(1) // Endless loop
     {
      PORTB = 0xFF; // Turn ON LED
      PORTC = 0xFF;
      PORTD = 0xFF;
      Delay_ms(5000); // 5 second delay
      PORTB = 0; // Turn OFF LED
      PORTD = 0;
      PORTC = 0;
      Delay_ms(5000); // 5 second delay
      }
}
 

einton

New Member
Yes dear using pic18f452, i tried ur later modified program but it is no different, leds are giving no respone,
i need to ask two things
1)how can i enchance my learning of mikroc, im working on c,soon revise it in few days.
2)should i transform my controller from breadboard to veroboard zif socket, when im finding no clue of getting breadboard wrong way, i have tested my breadboard with dmm .
 

gaspode42

Member
Einton

Try running the application through the debugger within Microc. Thats what I did with the code I sent you and you can see the values of the registers changing. If you can get that far and then it's still not working then your breadboard is probably incorrect. Can you post a schematic of what you have on your breadboard?
 

einton

New Member
Yes i try to sent u , i have also getting decided to change breadboard, dear can u tell what should i do for mikroc learning fine enough to make good program without hesitation.
 

Mr RB

Well-Known Member
MikroC compiler comes with tons of examples for the 18F452, look in your examples folder. If they are not there you can download them from the MikroE site, try in the EasyPIC5 section I think.

The examples start with things like "blink LED" etc and go right up to complex examples like using SD card and graphic LCD displays etc.

Try getting the "blink LED" example working first, then mess with the code to make it chase LEDs afterward.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top