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.

Difference between a PIC16F627 and PIC16F628A

Status
Not open for further replies.

marting

New Member
Hi all,

I have found a really strange issue.
I have this LCD clock written in ASM, and that runs fine on a PIC16F627.

If I program a 16F628A with the same code, I'll get a very weird thing, and that is that the Hour display en minute display is written as follows:

00h = 80
12h = 92
23h = 03
00h = 80
.. etc
this is the same for the minutes.

Now I use a conversion routine (see below) to convert a number from W to ones, tens etc etc to convert this into text to send to the display.
Could it be that this routine is behaving deffirent on a 628A???


All other stuff works fine (inputs, other characters on the display etc), its only the output/conversion of the hours/minutes..

anyone an idea??

[edit]
in MLAB IDE, i do not see any strange things if I debug the conversion!
[/edit]

Code:
;This routine downloaded from http://www.piclist.com
Convert:                        ; Takes number in NumH:NumL
                                ; Returns decimal in
                                ; TenK:Thou:Hund:Tens:Ones
        swapf   NumH, w
	iorlw	B'11110000'
        movwf   Thou
        addwf   Thou,f
        addlw   0XE2
        movwf   Hund
        addlw   0X32
        movwf   Ones

        movf    NumH,w
        andlw   0X0F
        addwf   Hund,f
        addwf   Hund,f
        addwf   Ones,f
        addlw   0XE9
        movwf   Tens
        addwf   Tens,f
        addwf   Tens,f

        swapf   NumL,w
        andlw   0X0F
        addwf   Tens,f
        addwf   Ones,f

        rlf     Tens,f
        rlf     Ones,f
        comf    Ones,f
        rlf     Ones,f

        movf    NumL,w
        andlw   0X0F
        addwf   Ones,f
        rlf     Thou,f

        movlw   0X07
        movwf   TenK

                    ; At this point, the original number is
                    ; equal to
                    ; TenK*10000+Thou*1000+Hund*100+Tens*10+Ones
                    ; if those entities are regarded as two's
                    ; complement binary.  To be precise, all of
                    ; them are negative except TenK.  Now the number
                    ; needs to be normalized, but this can all be
                    ; done with simple byte arithmetic.

        movlw   0X0A                             ; Ten
Lb1:
        addwf   Ones,f
        decf    Tens,f
        btfss   3,0
        goto   Lb1
Lb2:
        addwf   Tens,f
        decf    Hund,f
        btfss   3,0
        goto   Lb2
Lb3:
        addwf   Hund,f
        decf    Thou,f
        btfss   3,0
        goto   Lb3
Lb4:
        addwf   Thou,f
        decf    TenK,f
        btfss   3,0
        goto   Lb4

        retlw	0x00


		end
 
The 16F627 and 16F628A are almost the same, differences are minimal. See the attached file.
 

Attachments

  • 16f628a_migration_40048a.pdf
    137 KB · Views: 823
Difference between 627 and 628.

The only difference as far as I know between the A and not-A versions is that the non-A’s comparators don’t work properly in one of the modes.

The difference between 627 and 628 chips is only flash rom size. Did you switch to the 628 because you filled the ROM on the 627. If so, I would suspect a page fault. Check that you set RP0,RP1 and PCLATH correctly and that you save PCLATH in you interrrupt routine.

Mike
Edit, brain fart.
 
Re: Difference between 627 and 628.

Pommie said:
The difference between 627 and 628 chips is only flash rom size. Did you switch to the 628 because you filled the ROM on the 627. If so, I would suspect a page fault. Check that you set RP0,RP1 and PCLATH correctly and that you save PCLATH in you interrrupt routine.

As you have perhaps realised?, the 628 doesn't have any paging problems, because it only has 2K of program memory, and PIC's use 2K pages.

Really he needs to post the complete program, rather than just the binary to decimal routine from my tutorials, which I got off the PICList, and have used on various PIC's - including moving it to high memory on 16F877's.
 
Re: Difference between 627 and 628.

Nigel Goodwin said:
As you have perhaps realised?, the 628 doesn't have any paging problems, because it only has 2K of program memory, and PIC's use 2K pages.

Hence the brain fart comment. BTW, that conversion routine is insane. I'll have to sit down sometime and work out exactly what it is doing.

Mike.
 
Re: Difference between 627 and 628.

Pommie said:
Nigel Goodwin said:
As you have perhaps realised?, the 628 doesn't have any paging problems, because it only has 2K of program memory, and PIC's use 2K pages.

Hence the brain fart comment. BTW, that conversion routine is insane. I'll have to sit down sometime and work out exactly what it is doing.

It's fast, and it works perfectly - I've never bothered trying to work it out :lol:
 
Hi,

I am not applying the problem is in the conversion routine, it was just a thougt, because everuthing else works ok when I burn the code. All display finctions, inputs/outputs. delays etc. I just don't understand why it shows the time wrong on the lcd, but any other lcd stuf is displayed correctly. Thats why I thought that there is one more step befor its displays the time, and that's to convert it.

The whole program is rather large, thats why I need a 628.
I stripped some of the code to put it on a 627, works fine, same code gives a problem on the 628.

What also troubles me, is that a debug in mplab ide doesn't show anything wrong if I set the device to 628 and debug the whole conversion routine, the time display look fine..(als running it with pic simulator ide shows a correct working lcd..)
 
:oops:

Solved it by clearing the registers used for the conversion at initialization..


Thanks for all the input!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top