EEread in 16F685 results in same output in MPLAB-SIM

View: New views
5 Messages — Rating Filter:   Alert me  

EEread in 16F685 results in same output in MPLAB-SIM

by Harry H. Arends :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello List
 
I am tryuing to read a value out of the 16F685 EEPROM in MPLAB-SIM.
This is the routine:
 
EE_Read:
  bsf        STATUS,RP0  ; w=ADR
  movwf    EEADR
  bsf        EECON1,RD
  movf     EEDATA,w
  bcf       STATUS,RP0
  return
 
The W register contain the address of the location i want to read but this
function return always 0x01 in the W register.
Must one use some time delay reading the EEPROM or does MPLAB-SIM not handle
this correct.
 
Harry
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: EEread in 16F685 results in same output in MPLAB-SIM

by Nicola Perotto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For every PIC there are some little differences on how to read the eeprom.
You must read the datasheet of the 16F685, sure there are one example!

Harry H. Arends wrote:

> Hello List
>  
> I am tryuing to read a value out of the 16F685 EEPROM in MPLAB-SIM.
> This is the routine:
>  
> EE_Read:
>   bsf        STATUS,RP0  ; w=ADR
>   movwf    EEADR
>   bsf        EECON1,RD
>   movf     EEDATA,w
>   bcf       STATUS,RP0
>   return
>  
> The W register contain the address of the location i want to read but this
> function return always 0x01 in the W register.
> Must one use some time delay reading the EEPROM or does MPLAB-SIM not handle
> this correct.
>  
> Harry
>  

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: EEread in 16F685 results in same output in MPLAB-SIM

by Jinx-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> For every PIC there are some little differences on how to read the
> eeprom.You must read the datasheet of the 16F685, sure there are
> one example!

Harry's example is almost the same the d/s

BANKSEL EEADR ;
MOVLW CONFIG_ADDR ;
MOVWF EEADR ;Address to read
BSF EECON1,RD ;EE Read
MOVF EEDAT,W ;Move data to W

Harry, there's no time delay for reading EEPROM

"To read a data memory location, the user must write the
address to the EEADR register and then set control bit
RD of the EECON1 register, as shown in Example 10-1.
The data is available, at the very next cycle, in the
EEDAT register. Therefore, it can be read in the next
instruction"

and it should work in MPLAB. I used something like it a few
days ago with a 16F88




--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: EEread in 16F685 results in same output in MPLAB-SIM

by Olin Lathrop :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Harry H. Arends wrote:
>   bsf        STATUS,RP0  ; w=ADR

Don't do that.  Use BANKSEL.  That way you and everyone you ask to look at
the code knows the bank is set correctly for access to the desired location.
It also doesn't forget about RP1.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

RE: EEread in 16F685 results in same output in MPLAB-SIM

by Harry H. Arends :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

After reading the datasheet it seems that this device uses a differen scheme
that the 16F628 i am used to.
I know always RTFM :-))

-----Oorspronkelijk bericht-----
Van: piclist-bounces@... [mailto:piclist-bounces@...] Namens Jinx
Verzonden: dinsdag 12 augustus 2008 14:25
Aan: Microcontroller discussion list - Public.
Onderwerp: Re: [PIC] EEread in 16F685 results in same output in MPLAB-SIM

> For every PIC there are some little differences on how to read the
> eeprom.You must read the datasheet of the 16F685, sure there are one
> example!

Harry's example is almost the same the d/s

BANKSEL EEADR ;
MOVLW CONFIG_ADDR ;
MOVWF EEADR ;Address to read
BSF EECON1,RD ;EE Read
MOVF EEDAT,W ;Move data to W

Harry, there's no time delay for reading EEPROM

"To read a data memory location, the user must write the address to the
EEADR register and then set control bit RD of the EECON1 register, as shown
in Example 10-1.
The data is available, at the very next cycle, in the EEDAT register.
Therefore, it can be read in the next instruction"

and it should work in MPLAB. I used something like it a few days ago with a
16F88




--
http://www.piclist.com PIC/SX FAQ & list archive View/change your membership
options at http://mailman.mit.edu/mailman/listinfo/piclist


--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
LightInTheBox - Buy quality products at wholesale price!