Continue to Site

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.

  • 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.

Reading and understanding DATA sheets

Status
Not open for further replies.

camerart

Well-Known Member
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.
 
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
 
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. T

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.
 
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
 
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:
#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)
 
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:
You didn't say nothing about Oshonsoft till now MCC is for mplab X . Guess your back to the data sheet
 
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?
 
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.
 

Attachments

  • DewHeaterControl.bas
    1.1 KB · Views: 218
Last edited:
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.
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.
 
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
 
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
Hi J,
No preference, just the smallest in the box.
C.
 
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
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.

Hi S,
Ah, the same as I'm using at the moment, thanks.
c.
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
 
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.

Direct fro Oshonsoft site (https://www.oshonsoftbasiccompilers.com/pic16basiccompiler.php ):
upload_2017-7-14_7-13-11.png


John
 
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top