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

PIC indirect addressing

Status
Not open for further replies.

futz

Active Member
Though I love tinkering with PICs, I sometimes hate that they're missing stuff I've come to take for granted when programming the MCUs I started out with (lovely Motorolas). No real stack (oh ya, it's there, but there's no instructions to use it properly on a 16F886). No proper 16-bit instructions or registers. Indirect addressing is limited to one register instead of being useable anywhere and everywhere. No index registers. Snivel snivel snivel! :rolleyes: RISC machines can be a bear to program sometimes.

What's bugging me today is that I need indirect addressing badly in a subroutine, but my FSR is tied up in the ISR. I can't use it or of course the program crashes harshly the instant the ISR gets triggered while the PC is inside the subroutine.

Hmm... Maybe if I stack and unstack the FSR register inside the ISR so it's available outside the ISR... Hey! I just answered my own question! :D
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
In my ISR I save Status, W, FSR and PCLATH (on larger projects). Don't forget to set/clr the IRP bit.

Mike.
 

futz

Active Member
Pommie said:
In my ISR I save Status, W, FSR and PCLATH (on larger projects). Don't forget to set/clr the IRP bit.

Mike.
Ya, I was saving just Status and W (PCLATH not an issue with this little prog). Now I'm saving FSR too.

What's an IRP bit?
 

Pommie

Well-Known Member
Most Helpful Member
The IRP bit is the 9th bit of the FSR register and it lives in the status register.

Mike.
 

donniedj

Banned
For more robust registers and addressing use the 18F or the overkill 24F series.

As for the 16F series, I use multiple FSRs regularly. FSR, FSR2, FSRtemp. I just push FSR into FSRtemp and copy FSR2 into FSR. Then when fished copy FSR into FSR2 and pop FSRtemp back into FSR. If FSR will be used unexpectedly, add another FSRtemp2 to the mix.

There are many other aspects I hate having to CODE AROUND. But I learn to get it done and push product out because the customer cares not for the inner workings at the end of the day.
 
Last edited:

futz

Active Member
donniedj said:
For more robust registers and addressing use the 18F or the overkill 24F series.
I have dozens of different PICs, including quite a few various 18F's. The 18F's are really nice to code for. Not nearly so funky as the 16F's.

As for the 16F series, I use multiple FSRs regularly. FSR, FSR2, FSRtemp. I just push FSR into FSRtemp and copy FSR2 into FSR. Then when fished copy FSR into FSR2 and pop FSRtemp back into FSR. If FSR will be used unexpectedly, add another FSRtemp2 to the mix.
Exactly what I'm now doing. Thanks.
 

futz

Active Member
blueroomelectronics said:
I wish I could come up with a dsPIC30F series kit.
You could! What's stopping you? :p Can program those with the Inchworm+, right?

If it's surface mount that's worrying you, I have no fear of soldering them. I've built several surface mount kits and they all work fine. They're not for newb solderers though. You'd have to offer a pre-soldered version for them.
 
Last edited:

Diver300

Well-Known Member
Most Helpful Member
The PIC24FJ64GA002 series are available in DIL28 packages. If you want more I/O you have to go to surface mount.

They have 16 working registers, most of which can be used for indirect addressing. The stack is available. They are 16 bit processors.

In programming them I have found a lot of useful features such as:-

BRA Wn ;Branch with an offset of the contents of Wn
;Lookup tables in one line

Repeat Wn ;Repeat the following line Wn times

SL Wb,Wns,Wnd ;Wnd = Left Shift Wb by Wns
;This removes the need for loops in computed shifts

The biggest problem that I found with them is that the assembler is very different than for the Pic10 - pic18
 

blueroomelectronics

Well-Known Member
futz said:
You could! What's stopping you? :p Can program those with the Inchworm+, right?

If it's surface mount that's worrying you, I have no fear of soldering them. I've built several surface mount kits and they all work fine. They're not for newb solderers though. You'd have to offer a pre-soldered version for them.
Some dsPIC30F have DIP packages and they are compatible with the 5V Inchworm / Junebug. I just don't know what sort of things you'd specifically need them for.
 

Pommie

Well-Known Member
Most Helpful Member
blueroomelectronics said:
Some dsPIC30F have DIP packages and they are compatible with the 5V Inchworm / Junebug. I just don't know what sort of things you'd specifically need them for.
To play with.

mike.
 

blueroomelectronics

Well-Known Member
I like Marks site, been there before. Mark really like lasers and Nixie tubes.
I personally wouldn't use a 16bit dsPIC to decode IR is a bit of overkill. It's also easy to do that with a lowly 12F508 and I doubt any dsp instructions are really required for IR decoding.
As for the flat-panel that's cool but not really kit material.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top