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.

Unable to change register / manipulate memory

 

I'm having some trouble changing a register. I want to set up ADC0/ADC1 to use PWM Module 1 as a trigger, which means that I have to manipulate the register ADC0_TSSEL_R. I have tried using both the HWREG macro and the register defined in the LM4F232H5QD header file, but neither of them works.
HWREG(ADC0_BASE + ADC_O_TSSEL) =  HWREG(ADC0_BASE + ADC_O_TSSEL) | ADC_TSSEL_PS0_1; /* Not working */
ADC0_TSSEL_R |= ADC_TSSEL_PS0_1;  /* Not working */

I'm also unable to manipulate this register when debugging using the register view in Code Composer Studio. When I try to change it, it immediately returns to its original value, as if it would be read only. I have also tried editing the memory address i the memory view, but the same thing happens there. Any ideas what could be causing this? 

Edit: I'm using Code Composer Studio with a Stellaris LM4F232H5QD board.

 

  • Again - Bravo to you for this ADCTSSEL Register discovery - I never saw/noted it. 

    My M4F MCU (4F631) - shows different register definitions than you've used.

    #define ADC_TSSEL_PS0_M         0x00000003  // PWM Unit Select
    #define ADC_TSSEL_PS0_0         0x00000000  // PWM Unit 0
    #define ADC_TSSEL_PS0_1         0x00000001  // PWM Unit 1

    Thus my code would read:        HWREG(ADC0_BASE + ADC_TSSEL_PS0_M) =  ADC_TSSEL_PS0_1;    //  as there is no definition for base ADCTSSEL.

    Now after entering this line my ADC0 Register View shows "all" PS0, PS1, PS2, PS3 loaded with 0x02.  However when the program runs all revert to 0x00.

    Suspect we are in "trial/error" or unchartered territory at this point...

  • I reproduced this and we are looking into it.

  • I think there may be a documentation problem.  It looks like the bits are all shifted left by 4 from what is documented.  For example instead of using bits 1:0, use 5:4.  If you write 0xFFFFFFFF to that register you can see which bits accept the change.

  • I shifted the bits 4 steps to the left, and could successfully write new values into the register. Unfortunately I'm still not able to trigger my ADC conversions from PWM Module 1, Generator 1. I initialize my PWM Outputs in the same way for Module 0 and Module 1, and I just change my call to ADCSequenceConfigure, like so:

    Code for using PWM Module 0, Generator 0:
    ADCSequenceConfigure(ADC0_BASE, ADC_SEQ_NUM_ADC0, ADC_TRIGGER_PWM0, 0);  /* Module 0, Gen 0 */

    Code for using PWM Module 1, Generator 1:
    ADCSequenceConfigure(ADC0_BASE, ADC_SEQ_NUM_ADC0, ADC_TRIGGER_PWM1, 0);  /* Module 1, Gen 1 */
    HWREG(ADC0_BASE + ADC_O_TSSEL) =  HWREG(ADC0_BASE + ADC_O_TSSEL) | (ADC_TSSEL_PS0_1 << 4);

    Am I missing something when switching the trigger source for ADC? 

    Complete code:
    Init ADC: http://pastebin.com/c4KqYt9d  
    PWM Init: http://pastebin.com/wuuL5y6M 


  • I want to let you know that I have not forgotten about your issue.  It is being investigated.

  • Please try changing your TSSEL value as follows:

    HWREG(ADC0_BASE + ADC_O_TSSEL) =  HWREG(ADC0_BASE + ADC_O_TSSEL) | (ADC_TSSEL_PS1_1 << 4);

  • This did the trick! Thanks a lot for the help Joe!

  • Thank you for your patience and persistence and helping us identify a problem with the documentation.  Please also note that the text for each field says "PWM Generator 0/1" when it really should say "PWM Module 0/1".

  • I'm having some new issues with this again. Last time I was only using a single sample sequence (#0), and this workaround was working properly. But now I want to use all four sample sequences and I can't get it to work. To get sample sequence #1 going, I used ADC_TSSEL_PS1_1, where I suppose the bold 1 should have been a zero to indicate sample sequence 0. What should I do to get all four sample sequences working?

  • It seems I was missing some other initialization code regarding uDMA etc. and I managed to get all four sampling sequences working properly (at least that seems to be the case, so far).

  • Gentlemen,

    I'm working on stellaris LM4F232H5QC on a customized board and facing similar issue.

    I want to trigger ADC1 Sequencer 0 with the help of PWM Module1, Generator 1 but I'm not able to do so. I've read several threads here and precisely identified the problem.

    I'm using datasheet  DS-LM4F232H5QC-14007.2601 SPMS318E which is released in January 2013.

    According to this datasheet, PS0 settings are on Bits 5:4.

    I've tried modifying all 4 combinations to these bits but problem still persist.

    Note: I've made ADC1, Sequencer 0 functional with PWM Module0, Generator 0 and this works fine. Therefore I'm rulling out possibilities of incorrect ADC configuration.

    Can anyone suggest something...

     

    Regards

    Shriram

     

     

  • Shriram,

    The most recent datasheet for the Tiva equivalent part will have a better description of how to use PWM triggered ADC sequences. See the description of the ADCTSSEL register and this forum post for more details.

  • Thanks for suggestion John.

    Yes, there is one more version of data sheet has been released and definately I found it updated with respect to ADCTSSEL register section.

    However, the problem has been resolved.

    I made it working on Eval board of LM4F232H5QD by sequencially testing all possible 8 combinations of PWM and Generators (So I ensured that all generators all triggering adc). Key change was, Earlier I used to write ADCTSSEL manually instead of working with macros provided in stellaris ware (xxPS0_1.....). So I might have made mistake.

     

    Regards

    Shriram