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.

16F628A Code Problem

Status
Not open for further replies.
I have followed your earlier comments and added that CBLOC starting address. At that moment , what was important for me was to indicate the OP that he did not have proper format. thus my doubt still remains, whether the include would not take care of start of user definitions? and whether the user still needs to provide the CBLOC start point ( as this is controller dependent).

Try reading the include file, I suspect you're thinking it's far more than it is - which is really just a simple text substitution table.

EDIT:

OK, just been and tried it (after correcting the code to make it assemble), as already stated if you don't give CBLOCK a value it defaults to zero.
 
Last edited:
hi,
Beat me to it again, thats two a row!!

Done the same 'what if' check with include, confirms your findings.:)
 
The cblock command does not start at the free memory as would be sensible. Instead it starts at zero and so can cause problems with people that don't realise this. I posted the comment so the OP would not suffer this problem. This was posted as a "just in case" and somehow became the focus of this thread. Why is it that people can't just accept statements as just statements.

Personally, I'm getting sick of people (actually person) picking me up on everything I say.

I state something correct,
I'm asked for an explanation,
I explain,
Some totally irrelevant fact is then posted,
WTF?

Mike.
 
The cblock command does not start at the free memory as would be sensible. Instead it starts at zero and so can cause problems with people that don't realise this. I posted the comment so the OP would not suffer this problem. This was posted as a "just in case" and somehow became the focus of this thread. Why is it that people can't just accept statements as just statements.

Personally, I'm getting sick of people (actually person) picking me up on everything I say.

I state something correct,
I'm asked for an explanation,
I explain,
Some totally irrelevant fact is then posted,
WTF?

Mike.
Thanks, Mike, Ericgibbs and Nigel.
But don't you feel Microchip could well accommodate such facility, as we define a chip and also indicate the include file.
The MPLAB has been set to the said processor. I don,t find any reason why the compiler can't have an algorithm built in to start such CBLOC at the appropriate default point depending on chip selected, and give a message, in case the length of message exceeds the register limits.

Perhaps, if Microchip could include such facility, it would make the programmer's life comfortable.
 
Last edited:
Thanks, Mike, Ericgibbs and Nigel.
But don't you feel Microchip could well accommodate such facility, as we define a chip and also indicate the include file.
The MPLAB has been set to the said processor. I don,t find any reason why the compiler can't have an algorithm built in to start such CBLOC at the appropriate default point depending on chip selected, and give a message, in case the length of message exceeds the register limits.

Perhaps, if Microchip could include such facility, it would make the programmer's life comfortable.

I don't really see as it would, it's hardly difficult to use the command properly, if you even use it at all - because there's no actual need to if you don't want.

I want to specify things to go where I want them to, which may not be the same place as you do.

Assembler is the 'lowest level' method of programming, it gives you total control over everything possible - if you want it to do things for you, perhaps you should be looking at a high level language?.
 
Hi again

; SETUP THE I/O PORTS ETC

BSF STATUS,RP0
MOVLW 0x01
MOVWF TRISA
BCF STATUS,RP0
CLRF PORTA

ORG 0x00

I have a question. What does RP0 mean? What is wrong with 0x05? Also why is the org statement there? Most programs that I see on the internet, has the org statement on the top just before the general registers. Will it have any effect, when I leave out the org statement?
 
Hi again



I have a question. What does RP0 mean? What is wrong with 0x05? Also why is the org statement there? Most programs that I see on the internet, has the org statement on the top just before the general registers. Will it have any effect, when I leave out the org statement?

it is the same. It is bit"5" of the STATUS register and is called RP0, When a specific name has been given, why to use the bit number? see issues related to bank selection in the datasheet of 18F628A
 
Last edited:
I have a question. What does RP0 mean? What is wrong with 0x05?

0x05 is pretty meaningless, why not use it's name RP0?, it's a specific status bit designation.

Also why is the org statement there? Most programs that I see on the internet, has the org statement on the top just before the general registers. Will it have any effect, when I leave out the org statement?

Don't leave it out - move it to where it should be (before the BSF), the code won't assemble as it is.

I suggest you have a quick look at my tutorial codes, which have all the required parts in place.
 
Hi

Hopefully this is the last. I just want to know, is the code right as it is now? I have changed and corrected the errors, according to the posts.

Code:
; INCLUDE PIC16F628A

	LIST 		P=16F628A
	INCLUDE 	<P16F628A.INC>
	__CONFIG	_BODEN_OFF&_CP_OFF&_PWRTE_OFF&_WDT_OFF&_XT_OSC&_LVP_OFF&_MCLRE_OFF
	ERRORLEVEL	-302
	ERRORLEVEL	-203

; GENERAL REGISTERS

	CBLOCK  0x20

COUNT1
COUNT2

	ENDC

; PROGRAM START

ORG        0x00

; DISABLE COMPARATORS

MOVLW    0x07
MOVWF    CMCON

; SETUP THE I/O PORTS ETC

	BSF		STATUS,RP0
	MOVLW	b'1'
	MOVWF	TRISA
	BCF		STATUS,RP0
	CLRF	PORTA

; START

START

	BTFSS	PORTA,0
	GOTO	START

	BSF		PORTA,1
	CALL	DELAY

	BCF		PORTA,1
	CALL	DELAY

	GOTO	START

; SUBROUTINES

DELAY	DECFSZ	COUNT1,F
		GOTO	DELAY
		DECFSZ	COUNT2,F
		GOTO	DELAY
	RETURN

	END

I also checked your LED Flash tutorial. It explains quite a lot more than in the tutorial I used. It's late now, so I will check it out in detail tommorow after school. :D
 
hi,
It works for me.

Unzip this attachment, its an *.avi file, play it with Windows media player.:)
 

Attachments

  • led1.zip
    97.4 KB · Views: 152
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top