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.

Config word in MPLAB X?

Status
Not open for further replies.

Andy1845c

Active Member
Hello,
I spent some time this weekend getting back into ASM PIC programming after having not done anything with them for probably 10 years.
Can you set the configuration with a hex word still, or must you use the little wizard and copy/paste the block of setups into your ASM file?
I can't get it to work with the __config 0x3fdd for example, but works with the output of the configuration wizard.
 
Which PIC are you using?, anything modern has a bewildering array of options - it's usually easier to use the MCC to set the options, then cut and paste the code it generates.

I seem to recall the __config setting was changed to something else a few years back?.
 
It depends on which assembler you're using.

MPASM (from MPLABX V5.35 and prior) accepts '__config' or 'config', depending on the device
PIC-AS (from XC8/MPLABX 5.40 and above) only accepts 'config'

PIC-AS does not accept the same syntax as the older MPASM, so if you have a lot of older code/examples it might be worthwhile downloading MPLABX 5.35.
 
Thanks guys.
I am using a 12F675 I believe it is (at work now), and using PIC-AS compiler. I'll stop beating my head against the wall thinking its something on my end.
 
At least it's an old device, so has relatively few options to set :D
This is true... ;)

Having been out of this world so long - are PICs popular anymore? I see we don't even have a dedicated forum here anymore. Back when I was active here PICs and AVRs were the in thing... I remember going through the PIC tutorials you had published.
Whats the embedded micro to learn these days?
 
This is true... ;)

Having been out of this world so long - are PICs popular anymore? I see we don't even have a dedicated forum here anymore. Back when I was active here PICs and AVRs were the in thing... I remember going through the PIC tutorials you had published.
Whats the embedded micro to learn these days?
There's never been a dedicated PIC forum, the micro-controller forum WAS the PIC forum, and still is -minor ones were spun off separately to leave mainly PIC's in that forum.

PIC's are still the most popular.
 
If you like the little 8-pin packages you might consider switching to a more up-to-date device... something like the 16F18313 (8-pin) or it's slightly larger brother 16F18323 (14-pin). You'll get more of just about everything, and since the 12F675 is ancient, the 16F18313 is cheaper as well.

Of course, with the way IC stock is these days trying to actually get a chip is a real challenge!

Both of those are supported by MPASM and PIC-AS.

I only mention MPASM since PIC-AS is still new and you might run into issues trying to follow any tutorials or example code. PIC-AS was originally the back-end assembler of the XC8 C compiler, and as such it was never really intended as a standalone tool. It's slowly getting better, but as with all Microchip tools it still needs some work IMHO.
 
If you like the little 8-pin packages you might consider switching to a more up-to-date device... something like the 16F18313 (8-pin) or it's slightly larger brother 16F18323 (14-pin). You'll get more of just about everything, and since the 12F675 is ancient, the 16F18313 is cheaper as well.

Of course, with the way IC stock is these days trying to actually get a chip is a real challenge!

Both of those are supported by MPASM and PIC-AS.

I only mention MPASM since PIC-AS is still new and you might run into issues trying to follow any tutorials or example code. PIC-AS was originally the back-end assembler of the XC8 C compiler, and as such it was never really intended as a standalone tool. It's slowly getting better, but as with all Microchip tools it still needs some work IMHO.
I am just playing with chips I acquired back in the day. :) My goal was to see if I could get back into this and not spend any money. So I am trying to re-boot my PicKit 2 under windows 11 and play with my ancient collection of various controllers. haha
 
If you like the little 8-pin packages you might consider switching to a more up-to-date device... something like the 16F18313 (8-pin) or it's slightly larger brother 16F18323 (14-pin). You'll get more of just about everything, and since the 12F675 is ancient, the 16F18313 is cheaper as well.

The 12F1840 is a nice little 8 pin chip as well, and has double the program memory (4K) of the 16F18313 (2K) - I've got both in stock.

Pity they don't make 8 pin chips with more memory?.
 
Ok guys - make me feel dumb. I got everything to build for the tutorial I am following and it didn't work. So I stripped it down to just this as I wasn't seeing anything change when I went back and simulated it. I should see it set bit 5 in the status register to a 1, correct??
 

Attachments

  • 2022-03-07 21_34_15-.png
    2022-03-07 21_34_15-.png
    270 KB · Views: 258
I've hardly used PIC assembly in the last 20 years, but I believe you have to do some setup at the start of the code?

eg. this is the first bit of program, after variable defs etc., in an old design:

Code:
;
reset           goto    begin
                nop
                nop
                nop
intvec          goto    intrpt
   
begin           movlw   00              ;
                bcf     STATUS,RP0      ; Page 0
                movwf   PORTA           ; Ensure o/p's off
                movwf   PORTB           ;
;
                bsf     STATUS,RP0      ; Select page 1
;
; PAGE 1 Register setup ***
;
........
 
I suspect your code isn't running as that should work. Can you single step through the code?

Mike.
Edit, BTW,I don't like the use of memory addresses, why not use bsf STATUS,RP0?
 
You previously said you're using the PIC-AS assembler.
That main.asm file won't assemble using PIC-AS, for a number of reasons.

What version of MPLABX, PIC-AS, and how exactly are you building your source?
 
I'm at work now so I can look when I get home at version numbers, but I just downloaded this software last week so it should be the latest version of everything. I am going Production > Clean and Build Main Project to build and Debug > Debug Main Project to run the simulator. It looks like F7 is what would be "single step"? When I do this the program counter and the first two bits of the status register change but nothing else seems to work.
 
This is what I was trying to get across; the program space is officially supposed to start at address 5, not address zero.
The reset goto & no ops etc pad the extra locations.

12F675_Program_Memory.jpg
 
If you're using absolute mode, as long as you're not using interrupts you can start the program at 0, you don't have to skip to location 5.

Double check later on, but to get the PIC-AS assembler you would have to also download and install the XC8 C compiler.

If the file you're trying to assemble is named 'main.asm', and its contents are what's showing in post #11 that won't work. It may look like it does, but it doesn't. There's no code in the hex file. Also, a number of those CONFIG statements aren't valid for a PIC12F675.

As I mentioned, PIC-AS <> MPASM, and old asm programs won't assemble without making a number of changes. None of the code posted in this thread so far will assemble with PIC-ASs. There's a 40 page porting guide...
 
Last edited:
There's a 40 page porting guide...
Do you have a link for this?

It sounds like I would be best off going back to the older version of MPLABX with the MPASM assembler?

As I said before I am just trying to get back into this for learning. I don't really have a goal or project in particular. I played with this stuff years ago and got to where I could modify examples but never really understood how to navigate the registers fully. Coming back now with some experience in PLC programming, its actually a lot more clear in my head. I would sort of like to spend some time getting more familiar with assembly before moving on to C.

Am I doing myself a dis-service with the older software and old chips?
 

It sounds like I would be best off going back to the older version of MPLABX with the MPASM assembler?
Personal preferences, but I think so. You can always keep your current version and install the older one too.

Am I doing myself a dis-service with the older software and old chips?
That's a judgement call on your part. If you just want to refresh where you were at 10 years ago, then you could stay with "what you already have" before bothering to switch everything around.

You can use some of the newer devices with MPLABX 5.35, just not the latest and greatest.
If you switch to those you'll probably have to update your programmer, so that's more cash you'd have to fork out.

One of the big downsides with PIC-ASS is that almost every tutorial you'll find is written for MPASM.
If they had done a proper job of replacing MPASM then it wouldn't be so painful. Many consider PIC-ASS not ready for prime-time.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top