This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

question about main function



hi, every one could someone explain this code in details ? please I don't understant the int main function how is created ? even the Systick delay and total delay thank you
  • I have another question I want to know what is =-1 mean or ==1
  • These are very, very basic questions about the C language. This probably isn't the best forum to talk about it. This forum is here to discuss the particulars of the Tiva hardware and it's tools (like the C compiler). So it's going to be hard to explain everything.

    Are you talking a class? The class should have some reference or prerequisite material on programming in general and the C language. There are plenty of books and a google search of "C Language tutorial" should find some online information to get you started.

    main is the function all C programs use. It basically defines the start of the program.

    STATUS = -1; 

    sets STATUS variable to -1.

    MStatus == -1

    "Is the MStatus variable equal to negative 1?"

    The == operator is a test for equality, while = is an assignment.

  • thank you so much for your help yes am taking the class but the instructor does not giving enough information. can you explain part of function int32_t TotalDelay(int32_t Tcount) { int32_t STATUS = 0; while (Tcount > MAXcount) { STATUS = -1; SysTickDelay(MAXcount); Tcount = Tcount - MAXcount; } SysTickDelay(Tcount); return (STATUS); }
  • // Tcount is the number of clock cycles to delay
    int32_t TotalDelay(int32_t Tcount)
    {
    	int32_t STATUS = 0;
    	
    	// Check to see if the number of clock cycles
    	// is more than what SysTickDelay can accept.
    	// consult the datasheet section 3.3 to see that it
    	// is limited to 24 bits
    	while (Tcount > MAXcount)
    	{
    		// Change the return status
    		STATUS = -1;
    		// Delay the maximum amount
    		SysTickDelay(MAXcount);
    		// Reduce the amount of clock cycles to wait
    		// by how long we just delayed in SysTickDelay()
    		Tcount = Tcount - MAXcount;
    		// Now go back to the while() loop and check to see
    		// if we need to loop again
    	}
    	SysTickDelay(Tcount);
    	// This return status value does not make sense to me. Why
    	// would the caller care if we had to loop?
    	return (STATUS);	// Return 0, or -1 if we had to loop
    }

    Is this something you wrote? Is it working for you?

  • thank you so much that's right sorry about how the code show I wrote the code the same way but when I posted it show without skipping and spacing the from line to line