• AVR Freaks

Hot!16F1508: DAC errors in Assembler

Author
JDW
Junior Member
  • Total Posts : 101
  • Reward points : 0
  • Joined: 2009/07/23 23:46:02
  • Location: Japan
  • Status: offline
2019/09/09 01:31:16 (permalink)
0

16F1508: DAC errors in Assembler

I've programmed the 16F1508 for a couple years without issue, but until now I've never used the DAC.  When I tried to assemble my code in MPLAB v4.05 (MacOS), I get these 2 errors:
 
Symbol not previously defined (DAC1CON0)
Symbol not previously defined (DAC1CON0)
Symbol not previously defined (DAC1CON1)
 
Relevant Code:
 
banksel DAC1CON0   ; Bank 2
movlw   b'1000000' ; Enable DAC. +Source=Vdd. Output pins disabled.
movwf   DAC1CON0
movlw   d'12'      ; Vdd/32 x 12 -> 2.73v/32 x 12 = 1.02375v (threshold)
movwf   DAC1CON1

 
Any thoughts?
#1

6 Replies Related Threads

    ric
    Super Member
    • Total Posts : 27967
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: 16F1508: DAC errors in Assembler 2019/09/09 02:06:32 (permalink)
    +1 (1)
    Seems to be a disagreement between the datasheet writer and the header file author.
    According to C:\Program Files (x86)\Microchip\xc8\v2.10\pic\include\pic16f1508.h
    the register names are just DACCON0 and DACCON1
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    JDW
    Junior Member
    • Total Posts : 101
    • Reward points : 0
    • Joined: 2009/07/23 23:46:02
    • Location: Japan
    • Status: offline
    Re: 16F1508: DAC errors in Assembler 2019/09/09 03:43:27 (permalink)
    0
    Thank you, Ric.  Problem solved!
     
    I must say there are other errors in that 16F1508 datasheet.  On page 143 in section 16.3 paragraph two ends this way...
     
    "configured for DAC reference voltage output will"
     
    "Will..." what?  Nobody knows! :-)
     
    Anyway, thank you!
    #3
    pcbbc
    Super Member
    • Total Posts : 1703
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: 16F1508: DAC errors in Assembler 2019/09/09 04:12:29 (permalink)
    +1 (1)
    You can submit a support ticket pointing out the documentation problems, and then they may get corrected for the next poor individual who would otherwise have encountered them.
    #4
    ric
    Super Member
    • Total Posts : 27967
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: 16F1508: DAC errors in Assembler 2019/09/09 04:22:44 (permalink)
    +2 (2)
    JDW
    ...
    On page 143 in section 16.3 paragraph two ends this way...
     
    "configured for DAC reference voltage output will"
     
    "Will..." what?  Nobody knows! :-)

    I know ;)
    You're looking in the latest revision of the datasheet (E)
    I have a copy of revision C, where that paragraph is on the right hand column, and reads:

    Reading the DACxOUTn pin when it has been
    configured for DAC reference voltage output will
    always return a ‘0’.


    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    JDW
    Junior Member
    • Total Posts : 101
    • Reward points : 0
    • Joined: 2009/07/23 23:46:02
    • Location: Japan
    • Status: offline
    Re: 16F1508: DAC errors in Assembler 2019/09/09 17:28:39 (permalink)
    0
    ric
    You're looking in the latest revision of the datasheet (E)
    I have a copy of revision C, where that paragraph is on the right hand column, and reads:

     
    Silly me.  I had been thinking newer datasheet revisions were better than the old!  :-)
     
    Thanks, Ric.
    #6
    ric
    Super Member
    • Total Posts : 27967
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: 16F1508: DAC errors in Assembler 2019/09/09 21:41:46 (permalink)
    +1 (1)
    I really should pay more attention.
    Even though I gave you the right answer, it was from the wrong file.
    For assembly code, the relevant include file (on a Windows PC) is:
    C:\Program Files (x86)\Microchip\MPLABX\v4.05\mpasmx\p16f1508.inc
    and the relevant section contains:
    ;-----Bank2------------------
    LATA             EQU  H'010C'
    LATB             EQU  H'010D'
    LATC             EQU  H'010E'
    CM1CON0          EQU  H'0111'
    CM1CON1          EQU  H'0112'
    CM2CON0          EQU  H'0113'
    CM2CON1          EQU  H'0114'
    CMOUT            EQU  H'0115'
    BORCON           EQU  H'0116'
    FVRCON           EQU  H'0117'
    DACCON0          EQU  H'0118'
    DACCON1          EQU  H'0119'

     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #7
    Jump to:
    © 2020 APG vNext Commercial Version 4.5