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.

[PIC] STC

ahmar123

Newbie level 5
Newbie level 5
Joined
Jul 10, 2024
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
52
View attachment 197435
Software is Stuck on Checking Target MCU , Hex file is uploaded , Checked the Comport ok , Here is the code for led blink

Code:
#include <reg51.h>

sbit led1 = P2^0;

// Function to generate a delay in milliseconds
void delay(int ms) {
    int i, j;
    for (i = 0; i < ms; i++) {
        for (j = 0; j < 1275; j++) {
        }
    }
}

int main() {
    while(1){
        led1 = 0x01;  // Turn on the LED (set P2.0 high)
        delay(500);    // Delay for 500 ms
        led1 = 0x00;   // Turn off the LED (set P2.0 low)
        delay(500);    // Delay for 500 ms
}
}
Upload the hex file and click on download program , power on / off the board but still it stuck on the above screen shot problem saying checking target much , highlight the problem
 
Last edited by a moderator:
I'm not quite sure I understand what "Software is Stuck on Checking Target MCU" really means, but I'm guessing that you aren't seeing the LED turn on and off - perhaps it is just a faint glow.
The probable cause is your 'delay' function in that any half decent compiler, even t the "no optimisation" level, will treat the whole this a a NOP and not give you any delay at all. The reason is that the inner loop does nothing with 'j' except increment it and the compiler will therefore say that it does nothing of use and remove that part of the code. Then it will look at your outer loop and come to the same conclusion about the 'i' variable and rmove that as well.
What you will be left with (at best) is a function that is called and then immediately returns.
Instead you should use any delay function that your compiler (whatever that is but by the use of the 'sbit' type I'm guessing is MikroC) provides. Alternatively, if you don't want a "busy wait", then use a timer.
Susan
PS - I can't see anything by following your link at the top of your post.
 
Hi,

I also don´t understand the [PIC] in your title. What does it mean?
and "STC" is not descriptive either. (While others write a whole story in the headline)

The forum headline should be short but rather descriptive like a newspaper article headline.
In your case maybe "STCxxxx mircocontroller firmware upload problem"

***
Currently we don´t know:
* which exact microcontroller you use
* what PC software (and platform) you use
* how the PC is connected with your microcontroller
* how your microcontroller is powered


Klaus
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top