This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cannot Single step though code

OK, what silly mistake have I made this time..?

I have just downloaded uVision4. Got a simple bit of code to flash and LED on and off.

However, I cannot single step through the code. When I hit Start/Stop Debug session, all other option get greyed out. .

I seem to have gone through all the project options as well as copying my code to a new project. It looks like my problem is similar to Benjamin's (recently posted). tried all his fixes and still nothing works

Here is my code:

#define at91sam7s256
#include <at91sam7s256.h>


#define LED            (1<<0)   // PA0
#define BUTTON1        (1<<19)  // PA19

static void initialize( void);

int main(void)
{
    volatile long input;
        volatile int n;
    volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA;

    initialize();

    while(1)
    {
        input = (pPIOA->PIO_PDSR) & BUTTON1;
        input = 0;
        input = BUTTON1;
        if (((pPIOA->PIO_PDSR) & BUTTON1) == BUTTON1)
        {
                        pPIOA->PIO_SODR = LED;
        }
        else
        {
            pPIOA->PIO_CODR = LED;
            input = (pPIOA->PIO_PDSR) & BUTTON1;
        }
    }
}
static void initialize(void)
{
  //Turn on the peripheral clock.  Without this on, inputs do not actually register in the PDSR register
  volatile AT91PS_PMC   pPMC = AT91C_BASE_PMC;          // pointer to PMC data structure
  volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA;

  pPMC->PMC_PCER = (1<<AT91C_ID_PIOA);                 // enable parallel IO controller clock

  pPIOA->PIO_PER = (LED | BUTTON1);                     // Set PIO to control LED and button.
  // Initialize Input
  pPIOA->PIO_ODR = BUTTON1 ;                            // Disable outputs for INPUT pins. (not needed as all pins default input on reset)
  pPIOA->PIO_PPUER = BUTTON1;                          //Pullup Enable (not needed as all pullups are enabled on reset)

  // Initialize Output
  pPIOA->PIO_OER = LED;                                 // Enable output for LED.
  pPIOA->PIO_SODR = LED;                                // Turn LED off.
  pPIOA->PIO_PPUDR = LED;                               //Pullup disable
}

Please let me know

Thanks

Parents
  • The only (questionable) reason for using volatile for an auto variable is if attempting to implement a software loop, and you want to try to stop the compiler from optimizing away the loop.

    This is an interesting comment. You might consider whether the observable behaviour of the program would change if the first two of the following lines of code were removed:

            input = (pPIOA->PIO_PDSR) & BUTTON1;
            input = 0;
            input = BUTTON1;
    

Reply
  • The only (questionable) reason for using volatile for an auto variable is if attempting to implement a software loop, and you want to try to stop the compiler from optimizing away the loop.

    This is an interesting comment. You might consider whether the observable behaviour of the program would change if the first two of the following lines of code were removed:

            input = (pPIOA->PIO_PDSR) & BUTTON1;
            input = 0;
            input = BUTTON1;
    

Children