Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 19th August 2008, 04:42 AM   (permalink)
Default Register goes from 0x00 to 0xFF... ?

Hi folks,

I have a register that has 0 in it, when I move the content of this register to the W register, the 0x00 becomes 0xFF.

Can anyone tell me what is going on?
RobertD is offline  
Old 19th August 2008, 04:48 AM   (permalink)
Default

Post your code and state what PIC you are using. DECF temp,W or COMF temp,W could do this.
__________________
--- The days of the digital watch are numbered. ---

Last edited by kchriste; 19th August 2008 at 04:50 AM.
kchriste is offline  
Old 19th August 2008, 05:08 AM   (permalink)
Default

You could be reading from the wrong bank.

Mike.
Pommie is offline  
Old 20th August 2008, 03:10 AM   (permalink)
Default

I could be reading from the wrong bank indeed. I'm reading the value from EEPROM, and when I switch it over from the EEPROM register to the W register to work with it, it pops.
RobertD is offline  
Old 20th August 2008, 03:13 AM   (permalink)
Default

Quote:
when I switch it over from the EEPROM register to the W register to work with it, it pops
What does that mean?

Mike
Mike, K8LH is offline  
Old 20th August 2008, 05:18 AM   (permalink)
Default

Quote:
Originally Posted by RobertD View Post
I could be reading from the wrong bank indeed. I'm reading the value from EEPROM, and when I switch it over from the EEPROM register to the W register to work with it, it pops.
Did you assign EEPROM locations in the last part of your program?
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline  
Old 20th August 2008, 09:59 PM   (permalink)
Default

Yes, I have assigned 0x75 for the EEPROM location, and reading from it. It's moved from the EEDATA register to the W register then from the W to the SELECT register, which is where I need it, and that's when it goes from 0x00 to 0xFF.

I'm using the 16F88 data sheet EEPROM code for read/write. I get a value from AD which I "andf" with "00001111" and rotate right.

I think I read something about "and" masks that was someting there I had to watch for.

And it doesn't move the W register to the SELECT register when I call for it. Now that's puzzling. I included the SELECT register in the cblock in the beginning. It is at 0x02c, while NEW is at 0x075.


Code:
read
        banksel EEADR 
		movf 	NEW, W ;
		movwf 	EEADR ; Data Memory Address to read
		banksel EECON1 
		bcf 	EECON1, EEPGD; Point to Data memory
		bsf 	EECON1, RD ; EE Read
		banksel EEDATA ; Select Bank of EEDATA
		movf 	EEDATA, W ; W = EEDATA                
	            
        return                       

write
        banksel EECON1 ; Select Bank of EECON1
		btfsc 	EECON1, WR ; Wait for write
		goto 	$-1 ; to complete
		banksel EEADR ; Select Bank of EEADR
		movf 	NEW, W ;
		movwf 	EEADR ; Data Memory Address to write
		movf 	NEW, W ;
		movwf 	EEDATA ; Data Memory Value to write
		banksel EECON1 ; Select Bank of EECON1
		bcf 	EECON1, EEPGD ; Point to DATA memory
		bsf 	EECON1, WREN ; Enable writes
		bcf 	INTCON, GIE ; Disable INTs.
		movlw 	h'55' ;
		movwf 	EECON2 ; Write 55h
		movlw 	h'AA' ;
		movwf 	EECON2 ; Write AAh
		bsf 	EECON1, WR ; Set WR bit to begin write
		bsf 	INTCON, GIE ; Enable INTs.
		bcf 	EECON1, WREN ; Disable writes

       
        return                  ;    

 
;coming from A/D going to EEPROM

            swapf	ADRESH
	movlw	B'00001111'
	andwf	ADRESH
	rrf		ADRESH
	movfw	ADRESH
	movwf	NEW

Last edited by RobertD; 20th August 2008 at 10:19 PM.
RobertD is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
PIC code protection - read 0x00? BeeBop Micro Controllers 11 9th April 2008 04:05 PM
Why do i get a 0x00 always???? tkvenki General Electronics Chat 10 18th May 2007 10:03 AM
bus register blue6x General Electronics Chat 2 20th April 2005 01:49 AM
24c16 Question:how to read and write at address 0xFF to 7FF? GraveYard_Killer Electronic Projects Design/Ideas/Reviews 1 13th April 2005 09:34 AM
register &latch finst General Electronics Chat 2 20th January 2004 12:15 PM



All times are GMT. The time now is 03:38 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker