Porting 16F630 code to 16F628A

Discussion in 'Embedded Systems and Microcontrollers' started by jj_alukkas, May 29, 2010.

  1. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    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.
     
  2. bertus

    Administrator

    Apr 5, 2008
    15,646
    2,345
    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
     
  3. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    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..
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
    Code ( (Unknown Language)):
    1. ERRORLEVEL -302 ;remove message about using proper bank
    2.  
    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
    Code ( (Unknown Language)):
    1.  
    2. banksel TRISB            ;Since this register is in bank 1,
    3.                               ;not default bank 0, banksel is
    4.                               ;used to ensure bank bits are correct.
    5.   clrf    TRISB           ;Clear TRISB. Sets PORTB to outputs.
    6.   banksel PORTB         ;banksel used to return to bank 0,
    7.                                ;where PORTB is located.
    8.   movlw   0x55            ;Set PORTB value.
    9.   movwf   PORTB
    10.   ;note! You can also use banksel 0 go back to bank 0
    11.  
    This code will assemble to
    Code ( (Unknown Language)):
    1.  
    2.   000    1683     BSF 0x3, 0x5                   19:     banksel TRISB            ;Since this register is in bank 1,
    3.    001    1303     BCF 0x3, 0x6
    4.                                                   20:                              ;not default bank 0, banksel is
    5.                                                   21:                              ;used to ensure bank bits are correct.
    6.    002    0186     CLRF 0x6                       22:       clrf    TRISB           ;Clear TRISB. Sets PORTB to outputs.
    7.    003    1283     BCF 0x3, 0x5                   23:      banksel 0           ;banksel used to return to bank 0,
    8.    004    1303     BCF 0x3, 0x6
    9.                                                   24:                              ;where PORTB is located.
    10.    005    3055     MOVLW 0x55                     25:      movlw   0x55            ;Set PORTB value.
    11.    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
     
  5. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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.
     
  6. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    @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?
     
  7. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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.
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Do you have some hardware to program your MCUs? It is boring to only work with the MPLAB simulator
     
  9. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    I am planning to build this modified JDM based programmer...

    [​IMG]

    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?
     
    • sch.gif
      sch.gif
      File size:
      14.3 KB
      Views:
      257
  10. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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 ;)
     
  11. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    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??
     
  12. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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.
     
  13. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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" ;)
     
  14. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    Ohh.. I'll have to solve this problem first before making more problems for me :-D
     
  15. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    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..
     
  16. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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:
     
  17. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    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
     
  18. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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.
     
  19. jj_alukkas

    Thread Starter Well-Known Member

    Jan 8, 2009
    751
    5
    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..
     
Loading...