PDA

View Full Version : Problems setting config bits on 10F222 part



JimAvanti
- 17th September 2016, 19:07
I have used many different pics before, but I am having a problem using a 10F222. In compiler options I have PBPL unchecked and under the assembler tab I have "Use MPASM" Checked (I am using a 64bit operating system so it won't let me change that).
I am getting errors trying to set the config bits.

The following line gives me assembler errors:
@__config _IOFSCS_4MHZ & _MCPU_OFF & _WDT_OFF & _MCLRE_OFF & _CP_OFF

I have tried what other have used below and I get "illegal opcode (PIC10F222)":
@ Device PIC10F222, IOFSCS_4MHZ, MCPU_OFF, WDT_OFF, PROTECT_OFF, MCLR_OFF

I can't seem to figure out what will work.

Dave
- 17th September 2016, 19:50
According to the 10F222.INC file in MPLAB there is NO "PROTECT_OFF" directive. Try the config without that directive and see if it works.

I have used the config like such in the past:
#CONFIG
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ
#ENDCONFIG
and it works just fine.

JimAvanti
- 17th September 2016, 20:10
Dave,
I did try without the "PROTECT_OFF". I was testing different things and forgot I left that in there. I just tried what you sent me and I get errors with the #CONFIG and #ENDCONFIG. Maybe because I am using PicBasic ver 2.06C.
Anyway, I tried "@__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ" and I still get error "Found directive in column 1. (__CONFIG)"
I never had problems with the 16F or 18F chips. I am confused!





According to the 10F222.INC file in MPLAB there is NO "PROTECT_OFF" directive. Try the config without that directive and see if it works.

I have used the config like such in the past:
#CONFIG
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ
#ENDCONFIG
and it works just fine.

HenrikOlsson
- 17th September 2016, 20:53
Have you commented out what's in the MPASM .inc file or is that where you're changing the CONFIG?

__CONFIG is a directive and MPASM found it in column one where it expects to see labels, try indenting it.

/Henrik.

Dave
- 19th September 2016, 12:20
Jim, my __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ statement is also indented 1 place. The forum sometimes ingores spaces in pasted text.

JimAvanti
- 19th September 2016, 14:23
Henrik,

I did have the .inc file line commented out (That is the first thing I usually do when working with a new pic). I tried
"__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ" indented and not indented and
"@__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ" indented and not indented. No combinations worked.

I went back to the include file and replaced the existing commented out line with "__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ" and it worked.
Very strange that I couldn't get it to work in the PicBasic source, but at least it is working. I don't think I will be using 10F222 chips much anyway.

Thanks for you help.

Jim


Have you commented out what's in the MPASM .inc file or is that where you're changing the CONFIG?

__CONFIG is a directive and MPASM found it in column one where it expects to see labels, try indenting it.

/Henrik.

HenrikOlsson
- 19th September 2016, 14:39
This is from memory and I've got no way of doublechecking right now but if you want to get to the bottom of it you can always check/verify/try.

In the .inc file the __CONFIG is enclosed within an ASM/ENDASM block, it gets passed to the assembler as is and it is indented, as it should be.

When you comment it out of the .inc file and put it in your source file you need to tell the compiler to pass that line to the assembler (just as is the case with the .inc file). You do this by either enclosing it within a ASM/ENDASM block or using the single line ASM directive, @, just as you tried.

What I suspect happened in your case is that there is no space between the @ and the __CONFIG so __CONFIG ended up in column 1, hence the error (or is it actually only a warning?).

So, comment it out of the .inc file, then in your source

ASM
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ ; <---- Note the intendation
ENDASM
or

@ __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ ; <---- Again, note the intendation

/Henrik.

Scampy
- 19th September 2016, 18:19
I tend to use the ASM/ENDASM commands to set the config bits, for example (not related to your chip)



ASM
__CONFIG _CONFIG1H, _OSC_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM

JimAvanti
- 19th September 2016, 19:05
Henrik,

You are absolutely correct. I indented the entire line including the "@". It worked once I indented. I also tried the ASM/ENDASM without the "#" and that also worked.

Thanks,
Jim



This is from memory and I've got no way of doublechecking right now but if you want to get to the bottom of it you can always check/verify/try.

In the .inc file the __CONFIG is enclosed within an ASM/ENDASM block, it gets passed to the assembler as is and it is indented, as it should be.

When you comment it out of the .inc file and put it in your source file you need to tell the compiler to pass that line to the assembler (just as is the case with the .inc file). You do this by either enclosing it within a ASM/ENDASM block or using the single line ASM directive, @, just as you tried.

What I suspect happened in your case is that there is no space between the @ and the __CONFIG so __CONFIG ended up in column 1, hence the error (or is it actually only a warning?).

So, comment it out of the .inc file, then in your source

ASM
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ ; <---- Note the intendation
ENDASM
or

@ __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ ; <---- Again, note the intendation

/Henrik.

JimAvanti
- 19th September 2016, 19:06
Thanks Scampy,

That worked. I was using #ASM & #ENDASM instead of ASM & ENDASM.

Jim