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

ADC Peripheral Debug Window and ADC_CHSR[7:0]

The window that the IDE shows when you click on Peripherals -> Analog/Digital Converter doesn't seem to control the checkboxes properly for the Channel Status register bits ADC_CHSR[7:0].

I'm using an ATMEL AT91SAM7S32, and in my ADC init function I write 0xFF to the ADC_CHSR register, which should enable all 8 A/D channels to be A/D inputs.

But... only the checkboxes in the ADC window associated with ADC_CHSR[3:0] get checked.

I changed the code to:

ADC_CHSR = 1 << 0;
ADC_CHSR = 1 << 1;
ADC_CHSR = 1 << 2;
ADC_CHSR = 1 << 3;
ADC_CHSR = 1 << 4;
ADC_CHSR = 1 << 5;
ADC_CHSR = 1 << 6;
ADC_CHSR = 1 << 7;

and stepped through it with the debugger. I expected to see those 8 checkboxes get checked, one at a time, since the code was enabling 1 channel and disabling the other 7 at each 'C' statement.

Instead of that I got channels 0 - 3 to get checked one by one, with nothing happening for channels 4 - 7, ending up with the first 4 channels checked, like before.

Anyone know why all 8 channels don't seem to work (i.e., be able to be checked), or why disabling a channel doesn't seem to clear the associated checkbox?

Parents
  • Also, the checkboxes associated with the ADC's status register don't seem to change as you step through the ADC's ISR. However, if I use "run to cursor", and run to the last statement in the ISR, the status register checkboxes do appear to show correct, valid info (i.e., the CH[7:0] bits get cleared).

    For example, consider the following code in the ADC ISR for the case when all 8 A/D channels are enabled and have current, valid conversion results in them (i.e., the conversion results have not been read yet).

    volatile unsigned int status;
    volatile unsigned int result;
    
    status = ADC_SR;
    result = ADC_CDR0;
    status = ADC_SR;
    result = ADC_CDR1;
    status = ADC_SR;
    result = ADC_CDR2;
    status = ADC_SR;
    result = ADC_CDR3;
    status = ADC_SR;
    result = ADC_CDR4;
    status = ADC_SR;
    result = ADC_CDR5;
    status = ADC_SR;
    result = ADC_CDR6;
    status = ADC_SR;
    result = ADC_CDR7;
    

    If I use the F-10 key in the debugger to step through this code one 'C' statement at a time, and have the variables 'status' and 'result' in a watch window, the result variable seems to get loaded with the same values that are in the IDE's ADC window, but the value of the status variable never changes. The status variable always shows 0xFF for the lower 8 bits, indicating that there is valid data for all 8 channels that needs to be read.

    If I use run to cursor to step over this whole code sequence, the status variable appears to end up with the right status info for the 8 A/D channel conversion results (i.e., 0x00).

    Is it possible that the debugger just does not work right for single stepping through ISR code?

Reply
  • Also, the checkboxes associated with the ADC's status register don't seem to change as you step through the ADC's ISR. However, if I use "run to cursor", and run to the last statement in the ISR, the status register checkboxes do appear to show correct, valid info (i.e., the CH[7:0] bits get cleared).

    For example, consider the following code in the ADC ISR for the case when all 8 A/D channels are enabled and have current, valid conversion results in them (i.e., the conversion results have not been read yet).

    volatile unsigned int status;
    volatile unsigned int result;
    
    status = ADC_SR;
    result = ADC_CDR0;
    status = ADC_SR;
    result = ADC_CDR1;
    status = ADC_SR;
    result = ADC_CDR2;
    status = ADC_SR;
    result = ADC_CDR3;
    status = ADC_SR;
    result = ADC_CDR4;
    status = ADC_SR;
    result = ADC_CDR5;
    status = ADC_SR;
    result = ADC_CDR6;
    status = ADC_SR;
    result = ADC_CDR7;
    

    If I use the F-10 key in the debugger to step through this code one 'C' statement at a time, and have the variables 'status' and 'result' in a watch window, the result variable seems to get loaded with the same values that are in the IDE's ADC window, but the value of the status variable never changes. The status variable always shows 0xFF for the lower 8 bits, indicating that there is valid data for all 8 channels that needs to be read.

    If I use run to cursor to step over this whole code sequence, the status variable appears to end up with the right status info for the 8 A/D channel conversion results (i.e., 0x00).

    Is it possible that the debugger just does not work right for single stepping through ISR code?

Children
No data