PDA

View Full Version : RA6 & RA7 I/O setting on the 16F88



PICante
- 6th July 2008, 17:24
I would like to use RA6 & RA7 on the 16F88 as standard I/O. I haven’t been able to figure out (the datasheet is not helping me a lot) how to set the CONFIG1 (FOSC) bit 4, 1 and 0 to (%1XX00) without disturbing other settings. Can someone please explain how to accomplish this.


Thanks!

mackrackit
- 6th July 2008, 21:30
You can find all of the config settings in the *.inc file for the chip by going to program files, microchip, mpasm suite.. find the *.inc for your chip , open in notepad, go towards the end.

Looks like
_INTRC_IO

That should have the internal running and the two pins as I/Os.

BobK
- 7th July 2008, 03:25
Hi PICante,

I had the same problem with the 16F87 which is sister chip to the F88. Do a search for my thread entitled "Internal Osc help" dated January 12, 2007 and look at Bruce's reply. It worked for me.

HTH,

BobK

mackrackit
- 7th July 2008, 06:46
Now I am confused.

I went and read the post Bob mentioned and tried it. Did not work.

I do not have a 16F88 laying around, but set up a project in MPLAB.

When I use _INTRC_IO and read the config register I have the expected results.

When I use _INTRC_OSC_NOCLKOUT I get an error and the config register says LP.

skimask
- 7th July 2008, 08:00
Now I am confused.
I went and read the post Bob mentioned and tried it. Did not work.
I do not have a 16F88 laying around, but set up a project in MPLAB.
When I use _INTRC_IO and read the config register I have the expected results.
When I use _INTRC_OSC_NOCLKOUT I get an error and the config register says LP.
Unless I'm wrong, the P16F88.INC file in the MPASM doesn't have that config directive listed.
It's got these listed for oscillators:
;Configuration Byte 1 Options
_EXTRC_CLKOUT EQU H'3FFF'
_EXTRC_IO EQU H'3FFE'
_INTRC_CLKOUT EQU H'3FFD'
_INTRC_IO EQU H'3FFC'
_EXTCLK EQU H'3FEF'
_HS_OSC EQU H'3FEE'
_XT_OSC EQU H'3FED'
_LP_OSC EQU H'3FEC'

I think you want INTRC_CLKOUT.

mackrackit
- 7th July 2008, 08:34
We are looking at the same thing.

I picked _INTRC_IO because I think that should make the pins I/Os.

So what was Bruce talking about in Bob's post? The *.inc s are pretty much the same for the 88 and 87.

peterdeco1
- 7th July 2008, 10:30
Hi Everyone. I've only used the 'F88 once. I didn't have any problem with this header file:

OSCCON = $60 'set int osc to 4mhz
ANSEL = 0 'ALL INPUTS DIGITAL
ADCON0 = 0 'AD MODULE OFF
CMCON = 7 'COMPARATORS OFF
TRISA = %SELECT YOUR I/O'S
TRISB = %SELECT YOUR I/O'S
@ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON

mackrackit
- 7th July 2008, 11:08
@ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON
Now I get it...I think.

INTRC_OSC works when using PM as an assembler.

_INTRC_IO works with MPASM.

PICante
- 7th July 2008, 14:54
Hi guys, thanks for the responce!

I have been doing a few projects based on the 16F88 and they all have turned out a success until this time, the first time I needed RA6 & RA7 as I/O’s.

I use MPASAM and the first part of my code looks like this:

define OSC 8

OSCCON =%01110000

@__config_INTRC_IO ‘ added today, compiled OK but no I/O on RA6 or RA7

TRISB = %00000000

TRISA = %11001100

ANSEL = %00000000

CMCON = 7



All the other ports works just fine so.....


Thanks for being here!

mackrackit
- 7th July 2008, 15:59
At least it compiles :)

Try what skimask suggested
INTRC_CLKOUT
Or compile with PM and use
@ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON

One of them has to work.

Archangel
- 7th July 2008, 17:19
This chip as 2 ADCON registers too

PICante
- 7th July 2008, 17:19
I tried the “INTRC_CLKOUT” with MPASM it compiled well but still no I/O!
I use the 16F88.inc file as is, not edited.

There must be something I miss here; “INTRC_CLKOUT” does not make sense to me (no offence)! The “INTRC_IO” statement seems more logic to me, of curse I might be of the tracks here but that’s how I see it.

Referring to the 16F88 datasheet page 130 way down;

Bit 4, 1-0 FOSC<2:0>: Oscillator Selection bits.

I believe what I need is the fourth alternative:

“100 = INTRC oscillator; port I/O function on both RA6/OSC2/CLKO pin and RA7/OSC1/CLKI pin”.

Or… am I loosing it? (apart from my hair!)



Thanks guys!

mackrackit
- 7th July 2008, 20:09
I tried the “INTRC_CLKOUT” with MPASM it compiled well but still no I/O!
I use the 16F88.inc file as is, not edited.

Have you commented out the shebang line in the inc?
http://www.picbasic.co.uk/forum/showpost.php?p=6775&postcount=5

PICante
- 7th July 2008, 21:44
This is the last part of my untouched inc file:


;================================================= =========================
;
; Configuration Bits
;
;================================================= =========================

_CONFIG1 EQU H'2007'
_CONFIG2 EQU H'2008'


;Configuration Byte 1 Options
_CP_ALL EQU H'1FFF'
_CP_OFF EQU H'3FFF'
_CCP1_RB0 EQU H'3FFF'
_CCP1_RB3 EQU H'2FFF'
_DEBUG_OFF EQU H'3FFF'
_DEBUG_ON EQU H'37FF'
_WRT_PROTECT_OFF EQU H'3FFF' ;No program memory write protection
_WRT_PROTECT_256 EQU H'3DFF' ;First 256 program memory protected
_WRT_PROTECT_2048 EQU H'3BFF' ;First 2048 program memory protected
_WRT_PROTECT_ALL EQU H'39FF' ;All of program memory protected
_CPD_ON EQU H'3EFF'
_CPD_OFF EQU H'3FFF'
_LVP_ON EQU H'3FFF'
_LVP_OFF EQU H'3F7F'
_BODEN_ON EQU H'3FFF'
_BODEN_OFF EQU H'3FBF'
_MCLR_ON EQU H'3FFF'
_MCLR_OFF EQU H'3FDF'
_PWRTE_OFF EQU H'3FFF'
_PWRTE_ON EQU H'3FF7'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FFB'
_EXTRC_CLKOUT EQU H'3FFF'
_EXTRC_IO EQU H'3FFE'
_INTRC_CLKOUT EQU H'3FFD'
_INTRC_IO EQU H'3FFC'
_EXTCLK EQU H'3FEF'
_HS_OSC EQU H'3FEE'
_XT_OSC EQU H'3FED'
_LP_OSC EQU H'3FEC'


;Configuration Byte 2 Options
_IESO_ON EQU H'3FFF'
_IESO_OFF EQU H'3FFD'
_FCMEN_ON EQU H'3FFF'
_FCMEN_OFF EQU H'3FFE'



; To use the Configuration Bits, place the following lines in your source code
; in the following format, and change the configuration value to the desired
; setting (such as CP_OFF to CP_ALL). These are currently commented out here
; and each __CONFIG line should have the preceding semicolon removed when
; pasted into your source code.

;Program Configuration Register 1
; __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF
& _BODEN_OFF & _MCLR_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC

;Program Configuration Register 2
; __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF



LIST

mackrackit
- 8th July 2008, 00:57
This is the last part of my untouched inc file:


That is the inc file from MPASM, do not modify it. That is where you get info about the chip.

The inc file you modify is in the PBP directory. It looks like this.


NOLIST
ifdef PM_USED
LIST
include 'M16F88.INC' ; PM header
; device pic16F88, hs_osc, wdt_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F88, r = dec, w = -302
INCLUDE "P16F88.INC" ; MPASM Header
; __config _CONFIG1,_INTRC_IO& _WDT_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
Notice the ';' That is a comment for this type of file. The two lines between LIST and LIST with comments are the lines to change or if setting the fuses in code space comment out.

PICante
- 9th July 2008, 16:34
Thanks for your patience Dave!

Well, I commented out the two lines as you suggested recompiled and put the code into the PIC and it froze! Tried a few times and also tried to reset the PIC but noting, stone cold! I opened the inc file, restored it, recompiled the code and it was all back to normal.
I must have my stupid hat on this week, this thing just won’t fly!

mackrackit
- 9th July 2008, 18:55
If you ser the fuses in code space then comment the two lines. Otherwise do like you are in the inc file.

Personally I like to set up in the inc.

Does it work at all now?

PICante
- 10th July 2008, 17:29
I commented out the two lines in the inc file and added the ” @__config _CONFIG1,_INTRC_IO& _WDT_ON & _LVP_OFF & _CP_OFF” to the code right below the “@__config_INTRC_IO” line but it refuses to compile! I get “[235] opcode expected instead of ‘_hs_osc’” error! ?

If I remove the line it compiles and everything except RA6 & RA7 I/O run perfect as before.

I am confused to say the least!

Thanks for the support!

skimask
- 10th July 2008, 17:57
I commented out the two lines in the inc file and added the ” @__config _CONFIG1,_INTRC_IO& _WDT_ON & _LVP_OFF & _CP_OFF” to the code right below the “@__config_INTRC_IO” line but it refuses to compile! I get “[235] opcode expected instead of ‘_hs_osc’” error! ?
If I remove the line it compiles and everything except RA6 & RA7 I/O run perfect as before.
I am confused to say the least!
Thanks for the support!
http://www.picbasic.co.uk/forum/showthread.php?t=543
Have you tried this thread yet? And I do mean the whole thing, not just the first and/or last post, but everything in between, everything linked, and then try everything in there to get a feel for how everything works?
Not that you'll ever need to use everything in there, but down the road, something in this thread might come up and you'll have that knowledge in the back of your head ready to go...and it'll save you loads of time...then...

peterdeco1
- 10th July 2008, 18:10
I have an idea. Copy this code exactly and tell us if RA6 and RA7 ports flash an LED. Put about 100 ohms on 1 side of the LED. I just tried it with a 16F88 and it works for me.

OSCCON = $60 'set int osc to 4mhz
ANSEL = 0 'ALL DIGITAL
CMCON = 7 'COMPARATORS OFF

TRISA = %00000000 'ALL OUTPUTS
TRISB = %00000000 'ALL OUTPUTS
PORTA = 0 'PORTA LOW

@ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON
Pause 100 'SETTLE DOWN

START:
High PORTA.6 'ON LED
High PORTA.7
Pause 1000
Low PORTA.6 'OFF LED
Low PORTA.7
Pause 1000
GoTo START 'REPEAT FOREVER

skimask
- 10th July 2008, 18:25
I have an idea. Copy this code exactly and tell us if RA6 and RA7 ports flash an LED. Put about 100 ohms on 1 side of the LED. I just tried it with a 16F88 and it works for me.
One question is left unanswered though...is this with or without a modified 16f88.INC file?
And I'm not sure if an LED will flash with +5v on both sides and ground on both sides :D

peterdeco1
- 10th July 2008, 18:51
Sorry if I wasn't clear. It works for me without a modified inc file. And the LED's connect from the port pins to ground. Now come on. You knew that didn't you Skimask?

skimask
- 10th July 2008, 19:08
Sorry if I wasn't clear. It works for me without a modified inc file. And the LED's connect from the port pins to ground. Now come on. You knew that didn't you Skimask?
Yep, just quietly pointing out a few 'options'! :D

leisryan
- 31st July 2008, 05:03
If using MPASM use this!!! Use both config!!!

; To use the Configuration Bits, place the following lines in your source code
; in the following format, and change the configuration value to the desired
; setting (such as CP_OFF to CP_ALL). These are currently commented out here
; and each __CONFIG line should have the preceding semicolon removed when
; pasted into your source code.

;Program Configuration Register 1
; __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC

;Program Configuration Register 2
; __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF

leisryan
- 31st July 2008, 06:14
;************************************************* ***************
;* 16F88.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 01/07/04 *
;* Version : 2.45 *
;* Notes : *
;************************************************* ***************
don't forget to comment out the following in the 16F88.INC file


NOLIST
ifdef PM_USED
LIST
include 'M16F88.INC' ; PM header
; device pic16F88, hs_osc, wdt_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F88, r = dec, w = -302
INCLUDE "P16F88.INC" ; MPASM Header
; __config _CONFIG1, _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST

PICante
- 12th August 2008, 21:45
Thanks guys,

Just returned from my vacation!

>leisryan: I tried your suggestion but I get two warnings compiling and the PIC hangs if I program it despite the warnings.

Is there no possible way to set the CONFIG1 (FOSC) bit 4, 1 and 0 to (%1XX00) in the code without disturbing other settings?

Thank you!

skimask
- 12th August 2008, 22:40
Is there no possible way to set the CONFIG1 (FOSC) bit 4, 1 and 0 to (%1XX00) in the code without disturbing other settings?
You're asking the exact same question as in the original post and you have been given the answers you need to figure out how to do what you want to do.
Just as described in the link in post #19. It will cure almost 99.99999999999999999999% of your (and anybody else's) CONFIG fuse woes...if you read and comprehend the text of the post.

Archangel
- 12th August 2008, 23:53
Hi PICante,
Lots of speculation going on here, please give this a try:


@ __config _CONFIG1,_INTRC_IO
OSCCON =126 ' or 1111110 or $7E for 8mhz, 1101110 for 4mhz, 1011110 for 2 mhz . . .

page 40 of the data sheet I am looking at, sect. 4.6.3
Osccon bits 6:4 set osc speed, bit 3 when set makes primary clock, bit 2 set= stable, not set= not stable, bit 1:0 set as 10 = internal R/C as system clock<br>
edit: 1111110 = 126 not 62

PICante
- 13th August 2008, 07:46
Thanks skimask, I have read through what you suggested and all the links and I am sorry to say it did not get me anywhere. I tried a few things without really knowing what I was doing and none of it worked. Most of it was about the PIC18F family which is (in my view) much more advanced compared to the 16F88 which I am trying to figure out. I mean I have to learn to crawl before I can run. Reading stuff that reefer to things way beyond where my knowledge are at this point just messes up my head. I understand that looking from your level of knowledge this might look ridiculous.

Joe S. > Thank you, I will try it this evening and let you know.

skimask
- 13th August 2008, 10:29
Thanks skimask, I have read through what you suggested and all the links and I am sorry to say it did not get me anywhere. I tried a few things without really knowing what I was doing and none of it worked. Most of it was about the PIC18F family which is (in my view) much more advanced compared to the 16F88 which I am trying to figure out. I mean I have to learn to crawl before I can run. Reading stuff that reefer to things way beyond where my knowledge are at this point just messes up my head. I understand that looking from your level of knowledge this might look ridiculous.

Nope, not ridiculous at all, not even close. It's a common question, all too common. Somehow I think Microchip should have come up with a better way to do the CONFIG fuses in the first place. But the information in that link is the key... When you figure all that out, a lot of other things PIC related come into focus...

leisryan
- 13th August 2008, 12:44
It's a complete project i built it for my 12v security camera multiple dc ouput 9 event daily timer!!! Don't worry we used to bite our nails before believe me I too ridicule myself before without knowing it..... hope this helps you use mpasm as compiler in "view" tab then in compiler options.........project no.5 is complete

leisryan
- 13th August 2008, 12:50
if you still can't make it work review post no. 35 bro!!! goodluck!!!

PICante
- 13th August 2008, 22:30
Thank you very much Joe!

Now it works the way it should!
I will now try to backtrack through the datasheet WHY it works and hopefully learn from it!

Thanks again to all of you! :-)

Archangel
- 23rd August 2008, 08:25
Thank you very much Joe!

Now it works the way it should!
I will now try to backtrack through the datasheet WHY it works and hopefully learn from it!

Thanks again to all of you! :-)
Din framgång er på min ålder framgång! Många fisk i den här Datan Ark.

PICante
- 23rd August 2008, 10:32
Hi Joe,

I recognize the words but not the composition! It says something like this:


“Your success you on my age success! Many fish in that here computer ark.”

Archangel
- 23rd August 2008, 19:32
Hi Joe,

I recognize the words but not the composition! It says something like this:


“Your success you on my age success! Many fish in that here computer ark.”

So online translators are that good ;) It was supposed to say . . . Your success is my success, and there are many fish in those data sheets which is supposed to relate to my signature of learning to fish. Glad you are on track with your project, I got to learn from it too, thanks.