Porting 16F630 code to 16F628A

Thread Starter

jj_alukkas

Joined Jan 8, 2009
753
Hi,

I have plans to build this project http://www.ladyada.net/make/minipov/index.html which uses a 16F630 PIC. But I'm from India and here only 16F628A is available and I have bought one. Comparing datasheets and codes I found that Port B needs to be changed to port C for 628 and I did so. But still i get errors telling 'Register in operand not in bank 0. Ensure that bank bits are correct.' in 3 lines. Can anybody show me some light on this as Im totally new to microcontroller programming. I can understand the change needed to schematic, but do I need anymore changes to the program?? This is the original source code http://www.ladyada.net/media/minipov/minipov.asm Thanks in advance.
 

bertus

Joined Apr 5, 2008
22,277
Hello,

I am not that familiar with pic programming (just started).
Did you also change the include-line at the beginning?
The 'Register in operand not in bank 0. Ensure that bank bits are correct.' warning is not important, you can ignore it.
That seems to be something in the MPlab software.

Bertus
 

Thread Starter

jj_alukkas

Joined Jan 8, 2009
753
Thanks for the reply Bertus.

Yes I have changed the include line for the new pic.. I am new with programming too, so maybe my mistake in adding the files and building. I had MPLAB v6 while doing this and now downloaded the latest version yesterday. Will try with that. Also do u have any suggessions for how to start from basic compilation and programming in MPLAB for PIC 16F's? Thanks a lot..
 

t06afre

Joined May 11, 2009
5,934
302 Register in operand not in bank 0. Ensure that bank bits are correct.
This is a commonly seen reminder message to tell you that a variable that is being accessed in not in bank 0. This message was added to remind you to check your code, particularly code in banks other than 0. Review the section on banksel (banksel - Generate Bank Selecting Code) and bankisel (bankisel - Generate Indirect Bank Selecting Code (PIC12/16 MCUs)) and ensure that your code uses bank bits whenever changing from ANY bank to ANY other bank (including bank 0).
Since the assembler or linker can't tell which path your code will take, you will always get this message for any variable not in bank 0. You can use the errorlevel command to turn this and other messages on and off, but be careful as you may not spot a banking problem with this message turned off. For more about errorlevel, see errorlevel - Set Message Level.
This is from the MPLAB help. As you can see it is not an error or warning.
You can remove the warning message by inserting the following at the top of your file . But I think it is better to have it on. As you most of time work in bank 0
Rich (BB code):
ERRORLEVEL -302 ;remove message about using proper bank
I often use the banksel directive, as it makes it more easy to port code to other MCUs. You will still get the 302 message then using banksel directive. Here is an example
Rich (BB code):
banksel TRISB            ;Since this register is in bank 1,
                              ;not default bank 0, banksel is 
                              ;used to ensure bank bits are correct.
  clrf    TRISB           ;Clear TRISB. Sets PORTB to outputs.
  banksel PORTB         ;banksel used to return to bank 0,
                               ;where PORTB is located.
  movlw   0x55            ;Set PORTB value.
  movwf   PORTB
  ;note! You can also use banksel 0 go back to bank 0
This code will assemble to
Rich (BB code):
  000    1683     BSF 0x3, 0x5                   19:     banksel TRISB            ;Since this register is in bank 1,
   001    1303     BCF 0x3, 0x6
                                                  20:                              ;not default bank 0, banksel is 
                                                  21:                              ;used to ensure bank bits are correct.
   002    0186     CLRF 0x6                       22:       clrf    TRISB           ;Clear TRISB. Sets PORTB to outputs.
   003    1283     BCF 0x3, 0x5                   23:      banksel 0           ;banksel used to return to bank 0,
   004    1303     BCF 0x3, 0x6
                                                  24:                              ;where PORTB is located.
   005    3055     MOVLW 0x55                     25:      movlw   0x55            ;Set PORTB value.
   006    0086     MOVWF 0x6                      26:       movwf   PORTB
If you want learn how to swim you have to get wet. And the same goes for PIC programming. You have to do some programming in order to learn how to. Start with simple programs. As you learn you can create more advance apps. As an example. Your PIC has two 8 bit ports. But the 16f630 has two 5 bits ports. Why not modify your program so it only us 1 port for the 8 LEDs.
What do you use as programmer. I might recommend some lessons. But it will depend on your programmer
 

Markd77

Joined Sep 7, 2009
2,806
There is a simulator in MPLAB so you can step through the code and see what is happening.
Just go to Debugger, select tool, MPLAB SIM.
Getting to know the simulator will be invaluable.
 

Thread Starter

jj_alukkas

Joined Jan 8, 2009
753
@t06afre
Ohh So I do not need to Worry about it.. Thanks Sir..
I have MPlab v6 as well as the latest 8.x versions.. I also have Keil uVision and Proteus.. Which would be the easies to use for ASM programming? The problems i am having are related to source file and linking and all... I dont know where to start. I can learn to program myself by studying codes, but how do i start? Like how do i include files for my Pic and start? Just the basic routine to start and reach the place where to start typing the source code would be of great help... I used to do Verilog programming in college in Xilinx, so I guess I must include the files while programming for the PIc too.. I'm ready to learn as much as I can.. A long time dream.. ANyway Thanks a lot. Also Any suggessions for a good programmer software other than the ones I told?

@Markd77
I checked simulation then itself.. it jumps in steps according to loops, but If my memory is correct, I have seen a port simulation tool showing 1 and 0 in uVision and Xilinx.. Didnt see it in this. Any Idea how to show it?
 

Markd77

Joined Sep 7, 2009
2,806
You can give inputs to the ports with the stimulus. It's maybe a bit clunky to use but quite powerful. You can see port output with the simulator logic analyzer.
 

Thread Starter

jj_alukkas

Joined Jan 8, 2009
753
I am planning to build this modified JDM based programmer...



It supports PIC12C50x, PIC12F62x, PIC16FFxx, PIC16F62x and EEPROM 24Cxx. This PIC-Programmer was tested with PIC12C508 (A), PIC12C509 (A), PIC12F629, PIC12F675, PIC16F84A, PIC16F627, PIC16F628.

I hope this would be enough?
 

Attachments

t06afre

Joined May 11, 2009
5,934
Get a PICKIT 2, or clone. They are USB based and work much better. Besides if your PC do not have any RS232 port the cost for PICKIT, and the JDM+USB to RS232 converter will much the same. I have also heard that the JDM do not work very well with some USB to RS232 converters. Perhaps you can get the one Bertus have cheap. Since he become a moderator he has not have time to do any PIC programming. His PICKIT 2 is still in the box. (LoL just joking Bertus ;)
 

Thread Starter

jj_alukkas

Joined Jan 8, 2009
753
Hehe.. I have a 5 yr old pc and a laptop.. Programming and stuffs are done on the pc with serial and parallel ports.. i have programmed an AT90S2313 using the parallel port.. Im a student, so for now I'll have to go with this, but I'll get a PIC kit soon.. Can u please help me with the linking and including of files when starting a program??
 

t06afre

Joined May 11, 2009
5,934
Is the pic16f690 in your list. Microchip have 12 lessons with this chip. Using a very simple trainer that you can build your self. It uses 4 LEDs, one pot, and a push button.
 

t06afre

Joined May 11, 2009
5,934
By the way. You can build your own pickit 2 clone. Just Google pickit 2 clone. If you have questions during the project you can ask them here. You will find many variants I think this one is quite simple. http://electronicsadvices.blogspot.com/2009/04/full-featured-pickit2-clone.html In order to build a PICKIT 2 clone you must in some way get a 18f2550 chip, and know somebody that can help you with the programming of that chip. It is somewhat a "chicken and egg problem" ;)
 

Thread Starter

jj_alukkas

Joined Jan 8, 2009
753
Anyone knows anyway to add an external power supply to the JDM circuit I have posted?? My serial port is low on voltage.. Please help..
 

t06afre

Joined May 11, 2009
5,934
Are you sure it is the serial port, and not some fault in your programmer. Like have you tested it on other computers. Or tested a working JDM on your computer.
But this is also typical JDM behavior. They work now and then. You will probably spend more time debugging the programmer than the actual code. And you will always be thinking. It is my code that is wrong, or is it my programmer?:confused::mad:
 

Thread Starter

jj_alukkas

Joined Jan 8, 2009
753
YEs, its written all over the web that newer pc's have low power RS232 controller chips.. The communication b/n the programmer and the pc is good, data in and out test working properly in icprog and other programmers detect hardware automatically too.. But the power led lights up very dim and the programming led never lights at all.. Ic prog gives an error on writing the first block for verification failure.. I have no access now to buy a programmer for the present month, and I cant wait to build a pov light.. Can somebody help me with any programmer circuit which I can build without using a programmed pic like PICkit but uses the serial or parallel port and if needed, an external power supply but runs no matter what type of pc I have, (low powered Serial port problem).. Please
 

t06afre

Joined May 11, 2009
5,934
According to this http://www.jdm.homepage.dk/newpic7.htm The JDM is powered by the RTS pin on the RS232 port. What you could try is to use a working 9v battery instead of power from the RTS. the negative battery connector should be connected to pin 5 on the RS232 port (GND) and the + connector should replace the RTS signal. You should perhaps use a switch also on the battery.
 

Thread Starter

jj_alukkas

Joined Jan 8, 2009
753
I did a lot of research... JDM is pretty useless for a modern pc.. The battery trick didnt work either.. cos the programming voltage required is 13.5v and it needs to come from tXD pin.. so boosting the supply voltage for RTS is useless.. I saw many tricks everywhere of using optocouplers and switching an external supply voltage using it.. Also I read its not safe to use an external supply on a JDM.. Tired of JDM now... Switched to conquest programmer. It has hex inverters, so might help.. I read somewhere that Conquest will work where JDM doesnt.. Will let you know..
 
Top