picmicrocontroller
Class DataMemory

java.lang.Object
  extended by picmicrocontroller.DataMemory

public class DataMemory
extends java.lang.Object

This class represents the data memory of a PIC16F877. Data memory consists of 4 banks, each having 128 registers.

Author:
maho

Field Summary
protected  PIC pic
           
 
Constructor Summary
DataMemory(PIC pic)
          Main constructor that initializes the data memory.
 
Method Summary
 int AD_channel()
          Get the active AD converter channel.
 boolean AD_enabled()
          Checks if AD converter module is activated.
 boolean AD_started()
          Checks if AD conversion started.
 void AD_stop()
          Stops the AD conversion.
 void AD_write(int dval)
          Writes the conversion result into ADRESL and ADRESH registers.
 void clear(int address)
          Clears the Register at the given address
 void clearCarry()
          Set the carry flag of the status register to 0.
 void clearDigitCarry()
          Set the digit flag of the status register to 0.
 void clearZeroFlag()
          Set the zero flag of the status register to 0.
 Register getADCON0()
          Get content of ADCON0 register.
 byte getPCH()
          Get content of PCH register.
 Register getPORTA()
          Get content of PORTA register.
 Register getPORTB()
          Get content of PORTB register.
 Register getPORTC()
          Get content of PORTC register.
 Register getPORTD()
          Get content of PORTD register.
 Register getPORTE()
          Get content of PORTE register.
 Register getTRISA()
          Get content of TRISA register.
 Register getTRISB()
          Get content of TRISB register.
 Register getTRISC()
          Get content of TRISC register.
 Register getTRISD()
          Get content of TRISD register.
 Register getTRISE()
          Get content of TRISE register.
 byte output(int bank, int address)
          Gets the value of a register specified by bank number and adress value.
 byte read(int address)
          Read the content of the register from a given address.
 void reset()
          Clears all the Registers in the data memory
 void setCarry()
          Set the carry flag of the status register.
 void setDigitCarry()
          Set the digit flag of the status register.
 void setPCH(byte data)
          Set content of PCH register.
 void setPORTAbyPeripheral(byte data)
          Sets the value of PORTA.
 void setPORTBbyPeripheral(byte data)
          Sets the value of PORTB.
 void setPORTCbyPeripheral(byte data)
          Sets the value of PORTC.
 void setPORTDbyPeripheral(byte data)
          Sets the value of PORTD.
 void setPORTEbyPeripheral(byte data)
          Sets the value of PORTE.
 void setZeroFlag()
          Set the zero flag of the status register.
 void write(int address, byte data)
          Change the content of the register of a given address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pic

protected PIC pic
Constructor Detail

DataMemory

public DataMemory(PIC pic)
Main constructor that initializes the data memory. All registers are filled with 0.

Method Detail

read

public byte read(int address)
Read the content of the register from a given address. Bank value should be set before read operation.


write

public void write(int address,
                  byte data)
Change the content of the register of a given address. Bank value should be set before write operation. Checks and updates duplicate values in the data memory.


clear

public void clear(int address)
Clears the Register at the given address


reset

public void reset()
Clears all the Registers in the data memory


getPORTA

public Register getPORTA()
Get content of PORTA register.


getPORTB

public Register getPORTB()
Get content of PORTB register.


getPORTC

public Register getPORTC()
Get content of PORTC register.


getPORTD

public Register getPORTD()
Get content of PORTD register.


getPORTE

public Register getPORTE()
Get content of PORTE register.


getTRISA

public Register getTRISA()
Get content of TRISA register.


getTRISB

public Register getTRISB()
Get content of TRISB register.


getTRISC

public Register getTRISC()
Get content of TRISC register.


getTRISD

public Register getTRISD()
Get content of TRISD register.


getTRISE

public Register getTRISE()
Get content of TRISE register.


getADCON0

public Register getADCON0()
Get content of ADCON0 register.


getPCH

public byte getPCH()
Get content of PCH register.


setPCH

public void setPCH(byte data)
Set content of PCH register.


setZeroFlag

public void setZeroFlag()
Set the zero flag of the status register.


clearZeroFlag

public void clearZeroFlag()
Set the zero flag of the status register to 0.


setCarry

public void setCarry()
Set the carry flag of the status register.


clearCarry

public void clearCarry()
Set the carry flag of the status register to 0.


setDigitCarry

public void setDigitCarry()
Set the digit flag of the status register.


clearDigitCarry

public void clearDigitCarry()
Set the digit flag of the status register to 0.


AD_enabled

public boolean AD_enabled()
Checks if AD converter module is activated.


AD_started

public boolean AD_started()
Checks if AD conversion started.


AD_channel

public int AD_channel()
Get the active AD converter channel.


AD_write

public void AD_write(int dval)
Writes the conversion result into ADRESL and ADRESH registers.

Parameters:
dval - digital value produced after conversion

AD_stop

public void AD_stop()
Stops the AD conversion.


setPORTAbyPeripheral

public void setPORTAbyPeripheral(byte data)
Sets the value of PORTA. This method should be used by peripherals.


setPORTBbyPeripheral

public void setPORTBbyPeripheral(byte data)
Sets the value of PORTB. This method should be used by peripherals.


setPORTCbyPeripheral

public void setPORTCbyPeripheral(byte data)
Sets the value of PORTC. This method should be used by peripherals.


setPORTDbyPeripheral

public void setPORTDbyPeripheral(byte data)
Sets the value of PORTD. This method should be used by peripherals.


setPORTEbyPeripheral

public void setPORTEbyPeripheral(byte data)
Sets the value of PORTE. This method should be used by peripherals.


output

public byte output(int bank,
                   int address)
Gets the value of a register specified by bank number and adress value. This method should be used when a register is supposed to output a value to some peripheral.

Parameters:
bank -
address -
Returns: