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.

16f628 problem

Status
Not open for further replies.

zhaniko93

New Member
Code:
	list      p=16F628A            ; list directive to define processor
	#include <P16F628A.inc>        ; processor specific variable definitions



	__config _CP_OFF & _LVP_OFF & _WDT_OFF & _INTOSC_OSC_NOCLKOUT 
  clrw
   bsf STATUS, RP1
   movlw TRISA
    movlw TRISB

   bcf STATUS, RP1
   movlw 0xFF
  movwf PORTB
sas goto sas


	end
Can any1 tell me why doesn't it work? PORTB isn't set to 1 and TRISB and TRISA remain 0xFF (I saw it in PIC SIMULATOR IDE)
 
You can remove the clrw and replace the movlw TRISA and movlw TRISB with clrf TRISA and clrf TRISB
After a quick look at the datasheet, almost every pin on PORTB (except RB5) has a peripheral linked to it.


Edit: Wow what the hell, I hit enter to go to another line, not to submit the post. >_>
 
Last edited:
And why isn't PORTB set to 1 or even TRISB?
clrw
bsf STATUS, RP1
movlw TRISA
movlw TRISB

bcf STATUS, RP1
This Doesn't work! TRISB is left 0xFF after that!
 
Code:
    list      p=16F628A            ; list directive to define processor
    #include <P16F628A.inc>        ; processor specific variable definitions



    __config _CP_OFF & _LVP_OFF & _WDT_OFF & _INTOSC_OSC_NOCLKOUT 
  clrw
   bsf STATUS, RP1
   movlw TRISA
    movlw TRISB

   bcf STATUS, RP1
   movlw 0xFF
  movwf PORTB
sas goto sas


    end
Can any1 tell me why doesn't it work? PORTB isn't set to 1 and TRISB and TRISA remain 0xFF (I saw it in PIC SIMULATOR IDE)

hi,
Try this in the Sim.
You MUST turn OFF the comparators, CMCON
also you had selected BANK2 not BANK1

and its movwf not movlw...

Code:
   list      p=16F628A            ; list directive to define processor
    #include <P16F628A.inc>        ; processor specific variable definitions
    errorlevel  -302 , -207             ; suppress messages 302 [Bank] and 207 [label in column 1]

 

    __config _CP_OFF & _LVP_OFF & _WDT_OFF & _INTOSC_OSC_NOCLKOUT 


    org 0x0000

    movlw 007
    movwf CMCON




       bsf STATUS, RP0
    movlw 0x00
    movwf TRISA
       movwf TRISB
       bcf STATUS, RP0

       movlw 0xFF
      movwf PORTB

sas goto sas


    end
 
Last edited:
Why not use banksel TRISB and forget this bsf STATUS, RP0

You'll always be in the right bank and have more time for
and its movwf not movlw...
 
BANKSEL 1 and BANKSEL 0?
 
and after selecting the correct bank, compiler gives warnings anyway. why?
 
BANKSEL 1 and BANKSEL 0?

hi,
This image is from the MPLAB help files.

EDIT:
Use this line as part of the code header.

errorlevel -302 , -207 ; suppress messages 302 [Bank] and 207 [label in column 1]
 

Attachments

  • 000esp01.gif
    000esp01.gif
    5.6 KB · Views: 199
Last edited:
list p=16F628A ; list directive to define processor
#include <P16F628A.inc> ; processor specific variable definitions[label in column 1]


Code:
    __config _CP_OFF & _LVP_OFF & _WDT_OFF & _INTOSC_OSC_NOCLKOUT 
[B]errorlevel  -302 , -207             ; suppress messages 302 [Bank] and 207 [label in column 1][/B]

    movlw 007
    movwf CMCON


  BANKSEL TRISA

    movlw 0x00
    movwf TRISA
       movwf TRISB
    BANKSEL PORTA
       movlw 0xFF
      movwf PORTB

sas goto sas

end
gives bank warnings why?
 
Last edited by a moderator:
and also what does goto $ or goto $+7 or $-2 etc. mean?
 
list p=16F628A ; list directive to define processor
#include <P16F628A.inc> ; processor specific variable definitions[label in column 1]



__config _CP_OFF & _LVP_OFF & _WDT_OFF & _INTOSC_OSC_NOCLKOUT

errorlevel -302 , -207 ; suppress messages 302 [Bank] and 207 [label in column 1]

movlw 007
movwf CMCON


BANKSEL TRISA

movlw 0x00
movwf TRISA
movwf TRISB
BANKSEL PORTA
movlw 0xFF
movwf PORTB

sas goto sas

end

gives bank warnings why?

hi,
I just answered that point...
 
and also what does goto $ or goto $+7 or $-2 etc. mean?

The symbol '$' is the current program counter value.
So goto $+3; means the current PC value + 3

Do you have MPLAB IDE in your PC.????
 
hi,
When you get error messages, post an image of the error messages.
 
ericgibbs
Than you very much I just understood everything (sorry for bad english :))
 
Where did you have errors
----------------------------------------------------------------------
Debug build of project `C:\asm\asm.mcp' started.
Language tool versions: MPASMWIN.exe v5.37, mplink.exe v4.37, mplib.exe v4.37
Preprocessor symbol `__DEBUG' is defined.
Wed Dec 22 00:47:15 2010
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\asm\asm.o".
Clean: Deleted file "C:\asm\asm.err".
Clean: Deleted file "C:\asm\asm.hex".
Clean: Deleted file "C:\asm\asm.lst".
Clean: Deleted file "C:\asm\asm.cof".
Clean: Deleted file "C:\asm\asm.mcs".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F628A "asm.asm" /l"asm.lst" /e"asm.err" /d__DEBUG=1
Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" /p16F628A "asm.o" /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"asm.cof" /M"asm.map" /W /x
MPLINK 4.37, Linker
Copyright (c) 1998-2010 Microchip Technology Inc.
Errors : 0

Loaded C:\asm\asm.cof.
----------------------------------------------------------------------
Debug build of project `C:\asm\asm.mcp' succeeded.
Language tool versions: MPASMWIN.exe v5.37, mplink.exe v4.37, mplib.exe v4.37
Preprocessor symbol `__DEBUG' is defined.
Wed Dec 22 00:47:16 2010
----------------------------------------------------------------------
BUILD SUCCEEDED


Try this
Code:
 list p=16F628A ; list directive to define processor
 #include <P16F628A.inc> ; processor specific variable definitions[label in column 1]

 errorlevel  -302              ; suppress message 302 from list file

 __config _CP_OFF & _LVP_OFF & _WDT_OFF & _INTOSC_OSC_NOCLKOUT


	movlw 007
	movwf CMCON


	BANKSEL TRISA

	movlw 0x00
	movwf TRISA
	movwf TRISB
	BANKSEL PORTA
	movlw 0xFF
	movwf PORTB
sas: 
	goto sas

 end

You wasn't having real errors you just need to use the tab and set error level to 302

It's reminder message to tell you that a variable that is being accessed in not in bank 0.

But BANKSEL set's it right
 
Last edited:
I'm sorry I posted and look up where did all this come from LOL it wasn't showing your last 4 post

hi b80,
No problem, there are more bugs in this sites software than a Motel mattress....:rolleyes:

Regards
 
Last edited:
HELLPP!! I've benn programming my pic16f628 I hav bought just today and after programming it twice on third time i Can't any more? When I put it in **broken link removed** programmer red light used to shine but doesn't shine any more and when I click on PROGRAMM IT button, green one shines but it doesn't write actualy, because when it starts verifying, it fails and When I press read code button, it reads FFFFFFFFF... all whats wrong? When I put it on breadboard, It does what it was programmed to do (flash led) and so it isn't corrupt yes? what can I do?
 
P.S. When i connect it to COM port (programer), red LED shines and then goes off imediatelly and Programmer works fine (it programms other micros well)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top