autjih
Newbie level 3
- Joined
- Apr 26, 2013
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,314
include PIC16F873.lib
include Uart.lib
include Stirng.lib
include I2C.lib
OSC Define 20
SCL Define PORTA.0
SDA Define PORTA.1
Clk Define PORTC.7
RST Define PORTC.6
ROW1 Define PORTB.0
ROW2 Define PORTB.1
ROW3 Define PORTB.2
ROW4 Define PORTB.3
ROW5 Define PORTB.4
ROW6 Define PORTB.5
ROW7 Define PORTB.6
RXD Define PORTC.3
Prog Define PORTC.0
LED Define PORTC.1
if PROG = 0 THEN
GOTO ProgramMessage
ELSE
START:
READ, MSGLength, ShiftMSGSpeed
led = 0
RST = 1
PAUSE 500
RST = 0
DataBuffer = 0
ColPosition = 0
DataBuffer = 0
EEPROMAddress = 1
RunMessage:
IF PROG = 0 THEN GOTO ProgramMessage
LED = 0
ColPosition = ColPosition + 1
IF ColPosition = 37 THEN ColPosition = 1
I2CREAD , ( EEPROMAddress - ColPosition), [DataBuffer]
PAUSEUS 50
CLK = 1
PAUSEUS 1
CLK = 0
IF ScaleTime = ShiftMSGSpeed THEN
EEPROMAddress = EEPROMAddress + 1
ENDIF
IF EEPROMAddress = MSGLength THEN
RST = 1
PAUSE 10
RST = 0
EEPROMAddress = 1
ENDIF
OutputRowData:
IF DataBuffer = 1 THEN ROW1 = 1
IF DataBuffer = 2 THEN ROW2 = 1
IF DataBuffer = 4 THEN ROW3 = 1
IF DataBuffer = 8 THEN ROW4 = 1
IF DataBuffer = 16 THEN ROW5 = 1
IF DataBuffer = 32 THEN ROW6 = 1
IF DataBuffer = 64 THEN ROW7 = 1
PAUSEus 300
ScaleTime = ScaleTime + 1
GOTO RunMessage
ProgramMessage:
LED = 1
EEPROMAddress = 1
DataBuffer = 0
ROW1 = 0
ROW2 = 0
ROW3 = 0
ROW4 = 0
ROW5 = 0
ROW6 = 0
ROW7 = 0
Write_EEPROM:
SERIN RXD, [DataBuffer]
IF DataBuffer = 255 THEN GOTO Write_Length
If led = 1 then
led = 0
else
led = 1
endif
I2CWRITE, EEPROMAddress, [DataBuffer]
PAUSE 10
EEPROMAddress = EEPROMAddress + 1
GOTO Write_EEPROM
Write_Length:
MSGLength = (EEPROMAddress - 35)
WRITE 0,MSGLength
PAUSE 5
EEPROMAddress = 1
DataBuffer = 0
ColPosition = 0
GOTO START
END
include Uart.lib
include Stirng.lib
include I2C.lib
OSC Define 20
SCL Define PORTA.0
SDA Define PORTA.1
Clk Define PORTC.7
RST Define PORTC.6
ROW1 Define PORTB.0
ROW2 Define PORTB.1
ROW3 Define PORTB.2
ROW4 Define PORTB.3
ROW5 Define PORTB.4
ROW6 Define PORTB.5
ROW7 Define PORTB.6
RXD Define PORTC.3
Prog Define PORTC.0
LED Define PORTC.1
if PROG = 0 THEN
GOTO ProgramMessage
ELSE
START:
READ, MSGLength, ShiftMSGSpeed
led = 0
RST = 1
PAUSE 500
RST = 0
DataBuffer = 0
ColPosition = 0
DataBuffer = 0
EEPROMAddress = 1
RunMessage:
IF PROG = 0 THEN GOTO ProgramMessage
LED = 0
ColPosition = ColPosition + 1
IF ColPosition = 37 THEN ColPosition = 1
I2CREAD , ( EEPROMAddress - ColPosition), [DataBuffer]
PAUSEUS 50
CLK = 1
PAUSEUS 1
CLK = 0
IF ScaleTime = ShiftMSGSpeed THEN
EEPROMAddress = EEPROMAddress + 1
ENDIF
IF EEPROMAddress = MSGLength THEN
RST = 1
PAUSE 10
RST = 0
EEPROMAddress = 1
ENDIF
OutputRowData:
IF DataBuffer = 1 THEN ROW1 = 1
IF DataBuffer = 2 THEN ROW2 = 1
IF DataBuffer = 4 THEN ROW3 = 1
IF DataBuffer = 8 THEN ROW4 = 1
IF DataBuffer = 16 THEN ROW5 = 1
IF DataBuffer = 32 THEN ROW6 = 1
IF DataBuffer = 64 THEN ROW7 = 1
PAUSEus 300
ScaleTime = ScaleTime + 1
GOTO RunMessage
ProgramMessage:
LED = 1
EEPROMAddress = 1
DataBuffer = 0
ROW1 = 0
ROW2 = 0
ROW3 = 0
ROW4 = 0
ROW5 = 0
ROW6 = 0
ROW7 = 0
Write_EEPROM:
SERIN RXD, [DataBuffer]
IF DataBuffer = 255 THEN GOTO Write_Length
If led = 1 then
led = 0
else
led = 1
endif
I2CWRITE, EEPROMAddress, [DataBuffer]
PAUSE 10
EEPROMAddress = EEPROMAddress + 1
GOTO Write_EEPROM
Write_Length:
MSGLength = (EEPROMAddress - 35)
WRITE 0,MSGLength
PAUSE 5
EEPROMAddress = 1
DataBuffer = 0
ColPosition = 0
GOTO START
END