• AVR Freaks

How to add sfrs for dsPIC33FJ256GP710 adc channels?

Author
AncientOne
New Member
  • Total Posts : 17
  • Reward points : 0
  • Joined: 2009/05/16 17:05:11
  • Location: 0
  • Status: offline
2009/05/16 17:17:21 (permalink)
0

How to add sfrs for dsPIC33FJ256GP710 adc channels?

I'm trying to use multiple channels of the 12-bit adc on the dsPIC33FJ256GP710 but the header file doesn't have sfrs for all the adc channels, only ch0, and I can't figure out how to add the sfrs for the channels 1 thru 31. Consequently I'm getting lots of undefined symbol errors for the additional channels I'm trying to use. I tried replicating the code in the header file for ch0, changing to ch1, 2, ...., but the C30 compiler didn't like it. And simply adding the definitions in my code, following the code example in the header file for the dsPIC33FJ256GP710 also didn't work. How can I add the sfrs for the remainder of the analog input channels? Thanks!
#1

7 Replies Related Threads

    aschen0866
    Super Member
    • Total Posts : 4481
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    RE: How to add sfrs for dsPIC33FJ256GP710 adc channels? 2009/05/16 21:07:35 (permalink)
    0
    Both the header file (.h) and the linker script (.gld) need to be modified if those SFRs do exist in the chip. Basically, the header file needs extern declarations and the linker script needs to give those SFRs their memory addresses at the very end. If those SFRs are bit addressable, you can also declare bit-fields in the header file. Now, if you ever modify those files, make sure you move those files to your local project folder so that future compiler update would not overwrite those changes.
    #2
    MBedder
    Circuit breaker
    • Total Posts : 6773
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    RE: How to add sfrs for dsPIC33FJ256GP710 adc channels? 2009/05/17 04:34:53 (permalink)
    0
    I'm trying to use multiple channels of the 12-bit adc on the dsPIC33FJ256GP710 but the header file doesn't have sfrs for all the adc channels, only ch0, and I can't figure out how to add the sfrs for the channels 1 thru 31

    You are trying to find a black cat in a dark room, but there is no cat at allgrin

    The dsPIC33FJ256GP710 doesn't have individual ADC channel buffers. You have to use DMA (or ADC ISR) to put the ADC channel data to individual RAM locations instead.

    To avoid such issues in the future just read the datasheets before you start codinggrin
    #3
    AncientOne
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2009/05/16 17:05:11
    • Location: 0
    • Status: offline
    RE: How to add sfrs for dsPIC33FJ256GP710 adc channels? 2009/05/18 20:15:31 (permalink)
    0
    Thanks very much ashen088. Excellent suggestion!
    #4
    AncientOne
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2009/05/16 17:05:11
    • Location: 0
    • Status: offline
    RE: How to add sfrs for dsPIC33FJ256GP710 adc channels? 2009/05/18 20:21:35 (permalink)
    0
    MBedder:

    I have to believe you're mistaken as the Microchip pdf document 70210A states:
    "The ADC module contains a 16-word dual port RAM, to buffer the ADC results. The 16 buffer locations are referred to as ADC1BUF0, ADC1BUF1, ADC1BUF2, ...., ADC1BUFE, ADC1BUFF." and also that "As conversions are completed, the ADC module writes the results of the conversions into the analog-to-digital result buffer. The ADC result buffer is an array of sixteen words, accessed through the SFR space. The user application may attempt to read each analog-to-digital conversion result as it is generated. However, this might consume too much CPU time. Generally, to simplify the code, the module fills the buffer with results and generates an interrupt when the buffer is filled. The ADC module supports 16 result buffers. Therefore, the maximum number of conversions per interrupt must not exceed 16." and also "28.5.1 Buffer Fill Mode: When the Buffer Fill mode (BUFM<1>) bit in the ADC Control register (AD1CON2<1>) is '1', the 16-word results buffer is split into two 8-word groups: a lower group (ADC1BUF0 through ADC1BUF7) and an upper group (ADC1BUF8 through ADC1BUFF). The 8-word buffers alternately receive the conversion results after each ADC interrupt event. When the BUFM bit is set, each buffer size is equal to eight. Therefore, the maximum number of conversions per interrupt must not exceed eight."

    I believe that aschen0866 is correct in saying that the linker file needs to be updated with the SFR addresses for the different ADC buffer locations.

    Sorry I didn't include the above information about the 16 SFR's from 70210A.pdf in my original post.
    #5
    flubydust
    Super Member
    • Total Posts : 1286
    • Reward points : 0
    • Joined: 2005/05/19 13:44:42
    • Status: offline
    RE: How to add sfrs for dsPIC33FJ256GP710 adc channels? 2009/05/18 21:47:59 (permalink)
    0
    ORIGINAL: AncientOne
    I have to believe you're mistaken as the Microchip pdf document 70210A states:


    The dsPIC33FJ256GP710 datasheet tells you to look at section 16 of the FRM (DS70183) not section 28.
    #6
    aschen0866
    Super Member
    • Total Posts : 4481
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    RE: How to add sfrs for dsPIC33FJ256GP710 adc channels? 2009/05/19 07:41:34 (permalink)
    0
    I believe that aschen0866 is correct in saying that the linker file needs to be updated with the SFR addresses for the different ADC buffer locations.

    I was telling you a general method for correcting potential compiler mistakes such as missing or having incorrect SFR definitions. From reading the datasheet, I believe the chip you use doesn't have ADC1BUF1 through ADC1BUFF and you'll need to do what MBedder suggested.

    #7
    MBedder
    Circuit breaker
    • Total Posts : 6773
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    RE: How to add sfrs for dsPIC33FJ256GP710 adc channels? 2009/05/22 14:29:14 (permalink)
    0
    ORIGINAL: AncientOne

    MBedder:

    I have to believe you're mistaken as the Microchip pdf document 70210A states:
    "The ADC module contains a 16-word dual port RAM, to buffer the ADC results. The 16 buffer locations are referred to as ADC1BUF0, ADC1BUF1, ADC1BUF2, ...., ADC1BUFE, ADC1BUFF."...

    The 70210A describes a non-DMA ADC. Which has nothing to do with your dsPIC33FJ256GP710 thoughgrin
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5