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.

Registers add up, but don't transfer value.

Status
Not open for further replies.
"top_byte_reg" doesn't increase, nor decrease and no value moves into the "bottom_byte_reg"

Seems to be the same problem as before, that no values transfer from the W register to the F registers. Could it be that these registers are in bank B...? They're at 0x02c, and 0x02d.
 
PORTA pins are multiplexed with the built-in A/D converter and comparator in many PIC microcontrollers. If you're trying to set individual bits but you did not configure the PORT for digital I/O, you're very likely to get weird results. RA5 is input only in 18-pin PICs; RA6 and RA7 can be used for general I/O - assuming that you're using the internal oscillator - but you have to set the configuration bits properly.
BTW have you mentioned which PIC you're using? have you already posted the complete code on these forums?

Thanks, I have set up TRISA and ANSEL 00000010 which is RA1 input and analog, the rest being digital output. I was trying to get pins 3-4 up, but I tried 6-7 also with the same non-response. I'll try clearing ANSELH, see if it makes a difference.

I'm using a 16F88 which doesn't have ANSELH, so that's obviously not the problem. Seems the same problem is with PORTA as with "bottom_byte_reg" that no values get written for some reason.
 
Last edited:
I think I'll go back to the flashing LED program and get that working, then gradually introduce the rest of the code with that, and see which part of the code interferes with the pin output.

It's such a waste of time programming these chips when I have designed an application that does all that without commas and tittles, and without any knowledge of programming at all. An application that anyone can use, all they need is the idea, then the rest is a piece of cake. Let computers write the computer language, they're supposed to be so smart.
 
Last edited:
Could it be that these registers are in bank B...? They're at 0x02c, and 0x02d.
No, they are in bank 0, but are you sure that you're operating in bank 0?
Did you switch back to bank 0 after setting certain registers (TRISx, EEPROM registers, etc.)?
However, if you're debugging your program using the Special Function Registers window and the File Registers window, you could realize if an instruction clears a register in the wrong bank. In fact, the latest registers that has changed after each step are red coloured.
Good luck with your project.
 
Last edited:
Last thing I do is read the tables which are in bank 0 starting at 0x30, and return the values from W0 to W5 registers which are also in bank O, these add up no problem interacting with the W register. PORTA is in bank 0 and so are the two F registers bottom and top byte coming from the table and W0-5 results. The W0-5 registers add up OK in the W register, as these show in the "Watch" window of the MPLAB so I know they are working OK. I'm using "sim" mode, now that I figured out how to use it. It's a lot faster than debug mode.
 
Last edited:
Hummm, I get a blank window when I click view, disassembly listing. I'm in debug/release pickit2.
Hi,
View the disassembly listing after built/assemble/compile. You'll see the program memory used for each and every instruction.
 
Fantastic, now we're getting to the heart of the matter.

Update: Well, I see the register used, it says it increase the register top_byte, but the registers don't increase and the bottom_byte register doesn't transfer.... at least not on the view screen. It also says to put a one on pin 3-4, but the PORTA doesn't go up, it stays 0-0. So I'll keep plugging at it.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top