# Looking for Enhanced Mid-range PIC ref manual

Status
Not open for further replies.

#### BobW

##### Active Member
I've been hunting all over the Microchip site trying to find the Enhanced Mid-Range equivalent of the "Mid-Range MCU Family Reference Manual". Does anyone know if such a thing exists?

I've been trying to upgrade a project that originally used a 16F630 to a 16F1703, and I'm having a devil of a time trying to get it configured properly. I have the 16F1703 manual, but there are a few things that are rather ambiguous.

#### Nigel Goodwin

##### Super Moderator
Probably no such thing? - use MCC to configure the device, and then cut and paste the relevant sections (if you don't want to use what MCC produces directly) - the newer enhanced devices have so many options it's very confusing to try and set them all manually. Once you've got a working set of configs, it's easy enough to manually adjust them, but the initial settings are quite complicated.

Even now I often end up with the clock running at the wrong speed, and have to manually sort that out

##### Well-Known Member
I would put the 18F series in the category of enhanced mid range, they have several new commands that make programming easier, particularly if programming in Assembly.
Max.

#### Nigel Goodwin

##### Super Moderator
I would put the 18F series in the category of enhanced mid range, they have several new commands that make programming easier, particularly if programming in Assembly.
Max.
Not really, the enhanced mid-range series is the updates to the popular 16F 14 bit series, although many aspects of those have now been incorporated in the later 18F devices. The 18F aren't 'enhanced' because they were always like they still are

#### BobW

##### Active Member
What is MCC? This is the first I've heard of it.

Edit: Nevermind. I found it. Thanks for mentioning it. I'll let you know how it works out.

Last edited:

#### BobW

##### Active Member
Okay, another dumb question. How do you get MCC to generate assembly language configuration code instead of C code?

#### nsaspook

##### Well-Known Member
Okay, another dumb question. How do you get MCC to generate assembly language configuration code instead of C code?
Compile the C code.

#### BobW

##### Active Member
The C compiler produces assembly language source code?

#### nsaspook

##### Well-Known Member
The C compiler produces assembly language source code?
If you look at the disassembly listing it does.

#### BobW

##### Active Member
Yuck! I'd have to sort through hundreds of lines of other irrelevant code. Plus the disassembly listing doesn't appear to assign symbol names to the registers, making it unintelligible. It appears that it's easier just to look at the register view in MCC, and write my own code to set them to the values that it produces. Too bad they don't support assembly language.

For this project, it looks like the 1703 was not a good choice as a retrofit for the 630 after all. I'd thought they'd be a drop-in replacement hardware-wise, but I'm starting to see more problems that will likely turn it into an enormous job in addition to the whole register configuration problem. I think I'll save the 1703's for some other project.

#### nsaspook

##### Well-Known Member
Yuck! I'd have to sort through hundreds of lines of other irrelevant code. Plus the disassembly listing doesn't appear to assign symbol names to the registers, making it unintelligible. It appears that it's easier just to look at the register view in MCC, and write my own code to set them to the values that it produces. Too bad they don't support assembly language.

For this project, it looks like the 1703 was not a good choice as a retrofit for the 630 after all. I'd thought they'd be a drop-in replacement hardware-wise, but I'm starting to see more problems that will likely turn it into an enormous job in addition to the whole register configuration problem. I think I'll save the 1703's for some other project.
One of the pleasure of programming in asm, getting down and dirty.

#### BobW

##### Active Member
I don't really mind asm. For what I'm doing, it's more practical than C. It's just unfortunate that the number of configuration registers is so ridiculously high, regardless of the chosen language.

#### Nigel Goodwin

##### Super Moderator
I don't really mind asm. For what I'm doing, it's more practical than C. It's just unfortunate that the number of configuration registers is so ridiculously high, regardless of the chosen language.

You could always drop back to an older processor?.

#### BobW

##### Active Member
I may use a 16F676 for this project. It's also pin compatible with the original 630, and has analog which is what I needed to add. Unfortunately, I already have a bunch of 1703's on hand and don't have any 676's. Anyway, it's nothing urgent. In fact, I'm doing this because I have some spare time on my hands, and thought it would be a good opportunity to get up to speed on the enhanced chips. I do have another project using a 630 that's quite a bit simpler. It doesn't need an upgrade, but it may be an easier project to convert to a 1703. And if I can't get that to work, I guess I can start with a "hello world" project.

#### BobW

##### Active Member
Breaking news: I've now got the 16F1703 blinking an LED.
The world is my oyster.

#### nsaspook

##### Well-Known Member
Breaking news: I've now got the 16F1703 blinking an LED.
The world is my oyster.
Great news but ...
That's how it starts, first a blinking LED and then

#### BobW

##### Active Member
Yes, but it means that I finally got the system clock working, and in a predictable way. No small feat. I've never seen anything as convoluted as this. I had to create a program to toggle an output as fast as possible:
Code:
Start
movlw 0xFF
Loop
xorwf portC,f ; 3 cycles to change output state, x2 for full output cycle, x4 system clock pulses/instruction cycle
goto Loop     ; Thus, system clock is 24 times portC output frequency
Then measure it with a frequency counter to figure out the clock frequency. Then, try every combination of CONFIG bits and OSCCON bits, and record the results for posterity. Everything was reasonably straightforward for most clock frequencies, once I got the basics worked out, but I couldn't get it to run at 32 MHz. After much digging, I found that for that frequency, the configuration is radically different in all the various registers.

#### BobW

##### Active Member
With a predictable clock, my LCD routines are now working:

#### Mike - K8LH

##### Well-Known Member
Hey, Bob... Would you mind showing what your Oscillator setup instructions looked like, please?

Mike

#### BobW

##### Active Member
For 32 MHz internal oscillator:

Code:
    __config _CONFIG1, 0xEA0
__config _CONFIG2, 0x1E87

OscConConst equ b'11110000' ;32 MHz with 4x PLL

;In the main program:
movlw OscConConst
banksel osccon
movwf osccon
My final project operates at 32 MHz (internal oscillator), and this was the tricky one because a couple of things had to be done completely differently than for the other clock speeds. I did try all of the other internal oscillator speeds at the time as well, just to make sure that I understood the effects of the various configuration bits, but my notes are a bit sloppy. So, if another clock speed is required, I'd have to do some retesting.

Status
Not open for further replies.