1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Reading and understanding DATA sheets

Discussion in 'Microcontrollers' started by camerart, Jul 10, 2017.

  1. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,309
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    When I read a DATA sheet, sometimes I find it reasonably easy, but sometimes, it is very difficult. I don't know if there are others like me who need to set the registers etc like OSCCON CMCON0 , Comparators, WPU, OPTION_REG, ANSEL, ADCON0 etc and find it almost impossible to work out.

    Is there any way of making some kind of spreadsheet, where you choose the PIC then follow down the columns showing SPEED, PIN settings etc without having to trawl though the hundreds of pages. I accept that for some settings, the DATA sheets are fairly clear.
    Camerart.
     
  2. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,794
    Likes:
    134
    Location:
    morristown,tn
    I'm kind of liking MPlab code configurator
     
  3. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,309
    Likes:
    11
    Location:
    Dorset UK.
    Hi B,
    That looks just what I'm after, I'll investigate, thanks.
    C
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,888
    Likes:
    500
    Location:
    Cleveland, OH, USA

    I use MPLab 8.92 and am not familiar with its "code configurator" for such things as setting the peripherals. It does have a dropdown and dialog for setting the configuration bits, but that will not remind you, for example, to enable or disable the comparators.

    be80be Which version of MPLab are you using?

    As for the original question, I still use only the enhanced mid-range and lower chips. With those, you kind of get into a routine as to what needs to be set. Then if I used a chip with a new peripheral that I am not using, I check to see whether and how it needs to be turned off. Of course, if I am making use of that peripheral, then I study the section.

    John
     
  6. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,205
    Likes:
    640
    Location:
    Derbyshire, UK
    With your normal common devices, it's easiest to simply cut and paste the configuration section.

    And as you say, when you move to a new device, check what else might need doing (and what might need removing, or changing) as well.
     
  7. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,794
    Likes:
    134
    Location:
    morristown,tn
    MCC is a plugin for mplab x it's cool only thing I've had problems with is it's defines it lets you setup the whole chip and gives defines to run code I've had to use the defined code lol
    Like
    IO__RC0 = 1 ; didn't work but your ahead of the game
     
  8. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,794
    Likes:
    134
    Location:
    morristown,tn
    This is what it does it helps setting the right names but the defines dont seem to work as you'd think they would.
    Code (text):

    #define IO_RC3_TRIS               TRISCbits.TRISC3
    #define IO_RC3_LAT                LATCbits.LATC3
    #define IO_RC3_PORT               PORTCbits.RC3
    #define IO_RC3_WPU                WPUCbits.WPUC3
    #define IO_RC3_OD                ODCONCbits.ODCC3
    #define IO_RC3_ANS                ANSELCbits.ANSC3
    #define IO_RC3_SetHigh()            do { LATCbits.LATC3 = 1; } while(0)
    #define IO_RC3_SetLow()             do { LATCbits.LATC3 = 0; } while(0)
    #define IO_RC3_Toggle()             do { LATCbits.LATC3 = ~LATCbits.LATC3; } while(0)
    #define IO_RC3_GetValue()           PORTCbits.RC3
    #define IO_RC3_SetDigitalInput()    do { TRISCbits.TRISC3 = 1; } while(0)
    #define IO_RC3_SetDigitalOutput()   do { TRISCbits.TRISC3 = 0; } while(0)
    #define IO_RC3_SetPullup()      do { WPUCbits.WPUC3 = 1; } while(0)
    #define IO_RC3_ResetPullup()    do { WPUCbits.WPUC3 = 0; } while(0)
    #define IO_RC3_SetPushPull()    do { ODCONCbits.ODCC3 = 1; } while(0)
    #define IO_RC3_SetOpenDrain()   do { ODCONCbits.ODCC3 = 0; } while(0)
    #define IO_RC3_SetAnalogMode()  do { ANSELCbits.ANSC3 = 1; } while(0)
    #define IO_RC3_SetDigitalMode() do { ANSELCbits.ANSC3 = 0; } while(0)
     
  9. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,309
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    I am programming a 12F683 PIC and previously I had used one, but couldn't copy and paste, because I wanted to set up ANALOG PINs which wasn't in the original programs, I couldn't work out how to set up these:
    OSCCON = %01100000 'Internal 4MHz osc
    CMCON0 = %00000111 '7 'Comparators off
    WPU = 0 'Internal pull-ups = off
    OPTION_REG = %10000000 'Pull ups, TMR0, Prescaler
    ANSEL = %00001001
    ADCON0 = %00001101
    From others replies, not the DATA sheet, I got it working, which was what prompted my original question.
    be80be How would MCC help with this please? It appears that each bit would need to be picked out and entered in the Oshonsoft format, is this correct?
    C.
     
    Last edited: Jul 11, 2017
  10. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,794
    Likes:
    134
    Location:
    morristown,tn
    You didn't say nothing about Oshonsoft till now MCC is for mplab X . Guess your back to the data sheet
     
  11. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,309
    Likes:
    11
    Location:
    Dorset UK.
    Hi B,
    Sorry, I thought I was. I think I've answered my own question in last post, so thanks.
    C
     
  12. Superdat

    Superdat Member

    Joined:
    Mar 3, 2015
    Messages:
    114
    Likes:
    3
    The only datasheets that are easy to understand are for diodes! Well sometimes!
    For Chips I find reading through the bits I'm interested in 3 or 4 times helps. Each time I have a flash of understanding I make a note. If I'm in luck eventually the notes make sense then it's time to try it out.
    First few times I tried the datasheet for Max7219/21 seven segment LED driver, it made no sense, now having used it a lot it is all very obvious.
    Datasheets are either written by people who understand it totally and to them it is all too painfully obvious.
    Or they are written by people who don't fully understand and therefore cannot explain it clearly.
    You choose ;-)
    Sometimes especially in big ones like PIC/AVR there are what I can only assume are typos because different parts of the DS contradict each other. What chance do us mere mortals have?
     
  13. Superdat

    Superdat Member

    Joined:
    Mar 3, 2015
    Messages:
    114
    Likes:
    3
    Hi C
    Why are you doing the ADCON stuff? Out of interest? Oscillator type can be set in Oshonsoft Configuration bits along with MCLR and others.
    Then copy the hex result into your program (Generate Basic Code).
    My understanding is that all pins are Analogue unless ALL Digital is used or ANSEL is set for individual bits.
    Are you trying to use ADC? I think Oshonsoft does all the necessary once you use ADCIN
    I've attached a simple program I did for a single dew heater controller. It uses ADC to control the heater and has 2 digital pins one to an indicator LED via a transistor the other to a power transistor for the heater.
    Hope it helps.
     

    Attached Files:

    Last edited: Jul 12, 2017
  14. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,309
    Likes:
    11
    Location:
    Dorset UK.
    Hi S,
    I agree! Data sheets can be a challenge. I also have to read them multiple times, and some of them endlessly.
    I'm making a video, showing the Oshonsoft simulator, at a talk about Aduinos. I need a digital and an analog input. I've done it now, but for the analog, I had to copy someone else's program, not from understanding the data sheet.
    What PIC did you use for your heater? I sometimes have use for a lens warmer.
    C.
     
  15. Superdat

    Superdat Member

    Joined:
    Mar 3, 2015
    Messages:
    114
    Likes:
    3
    12f683
     
  16. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,309
    Likes:
    11
    Location:
    Dorset UK.
    Hi S,
    Ah, the same as I'm using at the moment, thanks.
    c.
     
  17. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,888
    Likes:
    500
    Location:
    Cleveland, OH, USA
    The 12F683 and 12F1840 in 8-pin DIP are exactly the same price ($1.22) at DigiKey. The 12F1840 has an enhanced instruction set among other enhancements and peripherals.

    Why do you prefer the 12F683?

    John
     
  18. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,309
    Likes:
    11
    Location:
    Dorset UK.
    Hi J,
    No preference, just the smallest in the box.
    C.
     
  19. Superdat

    Superdat Member

    Joined:
    Mar 3, 2015
    Messages:
    114
    Likes:
    3
    Oshonsoft doesn't support 12F1840, 12F683 can be bought for about £0.50 if you buy x5. Although a difference of £0.50 wouldn't necessarily make me chose the cheapest version.
    12f683 works for the 3 or 4 applications I've used it for so why complicate things. Don't forget professionals and amateurs often have very different perspectives.

    I try to make my comments pertinent to the question! Wouldn't be very helpful if I'd given you my code for a 16F887
     
  20. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,888
    Likes:
    500
    Location:
    Cleveland, OH, USA
    • Agree Agree x 1
  21. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    257
    Likes:
    15
    Location:
    Helsinki, Finland
    But Oshonsoft PIC basic and PIC16 basic support different chips. It is possible to have one license only.

    "OshonSoft PIC Basic Compiler supports the following MCUs from the Microchip 8-bit PIC Mid-Range architecture product line (selected PIC16F, PIC12F, PIC10F models):
    PIC10F320, PIC10F322, PIC12F609, PIC12F615, PIC12F617, PIC12F629, PIC12F635, PIC12F675, PIC12F683, PIC12F752, PIC16F72, PIC16F73, PIC16F74, PIC16F76, PIC16F77, PIC16F83, PIC16F84, PIC16F84A, PIC16F87, PIC16F88, PIC16F610, PIC16F616, PIC16F627, PIC16F627A, PIC16F628 ..."
    etc.
     

Share This Page