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.

pic cheat sheet

Status
Not open for further replies.

be80be

Well-Known Member
Any 1 no where you can down load pic assembly Instruction set that go into more details than the data sheet.
 
Any 1 no where you can down load pic assembly Instruction set that go into more details than the data sheet.
If you're using 16F PICs then you want the Mid-Range Manual. It goes into much better detail on everything than the datasheets. In fact, for some PICs the datasheets miss things that the MRM covers properly.

It's a must-read/must-have for 16F PIC programmers. And it'll help 18F users too. Lots of stuff is the same in both lines of chips.

Not sure if there is a corresponding 18F manual. My foggy memory says there is, but I can't find it right now.

EDIT: After searching for a while I'm pretty sure that's the manual. It was written before there were 18F's, but except for 18F differences it covers everything very well. Now watch me be wrong. :p
 
Last edited:
I would think this would be the best source. Who knows better than Microchip?

Have you seen how many mistakes are in the Microchip datasheets ? ;)

One example is the Eeprom write routines where they don't clear the CFGS bit. Works fine in the simulator but in real life you end up writing to your config bits rather than eeprom/data memory.

You'll find many datasheets where this information is still incorrect in the example code :p

But generally, the Microchip datasheets are a pretty good reference.
 
They do make mistakes, but when they are found, they usually provide an errata sheet. For example: https://www.electro-tech-online.com/custompdfs/2008/12/80214a.pdf

One should always do a search on errata sheets for a particular part.

One example is the Eeprom write routines where they don't clear the CFGS bit. Works fine in the simulator but in real life you end up writing to your config bits rather than eeprom/data memory.

Did you copy their routines verbatim? Perhaps that is your mistake then. Did you verify timing with their example? Many things may cause your unexpected results if you cut and pasted code.

The manual list all the commands and timing requirements. It is up to the designer to follow the spec. This is not to say that you violated any spec, but consider it before claiming the data sheet to be in error.
 
I learnt the hard way many moons ago not to just copy and paste the code from the datasheets ;)

I will copy and paste but will always go through the other parts of the registers and make sure every bit is properly set.

I lost a days worth of work debugging the CFGS problem many moons ago lmao.
 
Oh and speaking of mistakes .....

On friday after spending most of the day testing stuff to be posted out this week, I had a spare hour to have a play with one of the new products I'm designing.

I'd been working on some serial code for a while in MPLAB and it all seemed to be working fine. I thought I'd bung it on one of the processors and give it a test in real life.

Plugged the 18F1320 into the breadboard, powered it up and got garbage on the RS232 terminal. Then it reset itself and repeated this.

I then remembered to put the 0.1uf bypass cap across the power pins and the resets stopped. It worked as it should but the characters I was expecting were not appearing on the terminal.

I then tried different baud rates on the terminal, a different Serial port, a couple of USB-RS232 adapters and still got the same results.

Double checked the code - it all seemed fine.

Turns out I had a 4Mhz crystal on the circuit rather than the 10Mhz one I thought I was using. With HSPLL enabled, this meant I was running at 16Mhz rather than 40Mhz.

Sometimes its the simplest of things that throws you.
 
Oh and speaking of mistakes .....

On friday after spending most of the day testing stuff to be posted out this week, I had a spare hour to have a play with one of the new products I'm designing.

I'd been working on some serial code for a while in MPLAB and it all seemed to be working fine. I thought I'd bung it on one of the processors and give it a test in real life.

Plugged the 18F1320 into the breadboard, powered it up and got garbage on the RS232 terminal. Then it reset itself and repeated this.

I then remembered to put the 0.1uf bypass cap across the power pins and the resets stopped. It worked as it should but the characters I was expecting were not appearing on the terminal.

I then tried different baud rates on the terminal, a different Serial port, a couple of USB-RS232 adapters and still got the same results.

Double checked the code - it all seemed fine.

Turns out I had a 4Mhz crystal on the circuit rather than the 10Mhz one I thought I was using. With HSPLL enabled, this meant I was running at 16Mhz rather than 40Mhz.

Sometimes its the simplest of things that throws you.

That is so true.

One time a coworker and I were troubleshooting a design that had to ship the next day. The IEEE interface was not working. We had been working over 12 hours that day on the problem. I typed in commands on the computer and still nothing. My co-worker raises his arms in frustration and says "What the hell is the problem" I stared at him for a moment until I realized he was holding the IEEE cable in his hand unconnected to anything... Hehe go figure. :eek:
 
Last edited:
The datasheet of the 18F4585 explains the "window" allowing to peek the CAN related registers through a fixed position in RAM, in a totally wrong way which makes its use, useless.

Even the explanation obtained after raising a ticket, was uncomplete / inexact, raising more doubts.

There is one micro, I forgot which one, where the register ALUSTA is mentioned. After asking everywhere you find out that such a register does not exist for that micro.
 
Another issue (which might have been fixed) was that in most previous versions of MPLAB, writing a USART result to file only wrote the bottom 7 bits so you couldn't write a number greater than 127 to file.

I raised a ticket with Microchip ages ago about it but it still wasn't fixed two or three MPLAB releases later even though they acknowledged (eventually) that there was a problem.
 
Thats all good piclist mid-range manual done have and been there. lol
What I'm looking for I ran into it on the net but can't find it now. It told how to use the 35 Instruction with a piece of code to show you to. like this
Code:
bsf     STATUS,RP0       ; select Register Page 1
and that it means bit set f
I have seen it same thing done with banksel
Code:
banksel TRISB           ;Since this register is in bank 1,
                          ;not default bank 0, banksel is 
                          ;used to ensure bank bits are correct.
And it a directive
Banksel produces two lines, like the example below, as long as you know what bank you're already in you don't need to use both lines - so it's slightly less efficient.

Code:

BSF STATUS , RP0
BCF STATUS , RP1
MOVLW 0x06
MOVWF ADCON1
BCF STATUS , RP0
BCF STATUS , RP1
Quote from Nigel Goodwin
 
Last edited:
What I'm looking for I ran into it on the net but can't find it now. It told how to use the 35 Instruction with a piece of code to show you to. like this
Code:
bsf     STATUS,RP0       ; select Register Page 1
and that it means bit set f
I have seen it same thing done with banksel
Code:
banksel TRISB           ;Since this register is in bank 1,
                          ;not default bank 0, banksel is 
                          ;used to ensure bank bits are correct.
And it a directive
Oh. Why didn't you say so? Sounds like you want the MPASM manual.

Banksel isn't an instruction/opcode though.
 
Last edited:
Banksel isn't an instruction/opcode though

Yes. It's a macro.
 
I no but I found what I was looking for thanks for the Input all
Banksel isn't an instruction/opcode though
It's part of mplab MPASM assembler
 
It's not assembler but macro. MPLAB convert it to assembler. MPLAB has the information of the register and convert this into bank select instructions.
 
I have read data sheets howto's tutorials but what I was looking for was right on my computer It's in the Mpasm assembler Help file. And I don't want to for get Nigel's even after what chips I first got he didn't use any of them. But that's OK I now have all of them. and learn a lot to boot. If
I could only find a brake out board for a pic 32 I could start learning it to . Thanks for all the help

Burt
 

Attachments

  • 08971-03-L.jpg
    08971-03-L.jpg
    113.3 KB · Views: 250
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top