Shop OBEX P1 Docs P2 Docs Learn Events
Write to EEPROM / Serial out problem — Parallax Forums

Write to EEPROM / Serial out problem

ArchiverArchiver Posts: 46,084
edited 2004-01-12 20:54 in General Discussion
I'm trying to store 16 samples in the EEPROM and then serial out put
them to a PC when input 1 is pressed.
1)Could somebody tell me why my program want show/write any EEPROM
memory locations used in the memory map.
2)The serial out statment I'm also stuck on as I need to get the
data from the EEPROM memory locations.

'{$STAMP BS2}
'Data Logger Assignemt
'BS1.bs2
'G Evans
'January 2004

MaxSamples CON 16
ADC CON 11 ' pin slect active low
DIO CON 14 ' Data Pin
CLK CON 13 ' Sets clock pin to 13
TX CON 16 ' Sets transmission pin to
16
N9600 CON $4054 ' Sets baud rate as a
constant

NSamples VAR Byte ' Counts the number of
samples taken
add VAR Word ' Address to write sample
value in EEPROM
Sampval VAR Word ' Store for ADC value
SampValLo VAR SampVal.LOWBYTE
SampValHi VAR SampVal.HIGHBYTE
Value VAR Word

adcctrl VAR Nib ' ADC control nibble
adcchan VAR adcctrl.BIT0 ' ADC channel number (alias)
adcctrl=%1101: adcchan=1 ' Set up ADC control nibble
and channel no

DIRS=$00 ' Sets Input pin 1 as start
buttom
OUTPUT 7
'---[noparse][[/noparse]Main program]
StartDelay:
IF IN0=0 THEN Startdelay: 'If input 0 is 1 then start
data capture

Again:
PAUSE 250 ' pause statement to take 4
samples per second

GOSUB READADC ' Read ADC value and then
return to main program

'DEBUG CLS, DEC Sampval ' clear debug screen then
display dec sampval
DEBUG "Sample value ", IHEX sampval,CR

value=sampval
WRITE add,value.LOWBYTE ' write data to EEPROM
WRITE add+1,value.HIGHBYTE


Nsamples=Nsamples + 1 ' Increment count number
IF Nsamples =>Maxsamples THEN Fin1: ' finish data collection when
Max number of samples-
' reached
GOTO Again
Fin1:
OUT7=1

RoutineDelay:
IF IN1=0 THEN Routinedelay: 'If input 1 is 1 then carry on
program and transmit

SEROUT TX,N9600,[noparse][[/noparse]0-010] 'Transmit data from EEPROM to
serial port
DEBUG ? "Spend data to serial port" ' test statment to check out
operation
END

'---[noparse][[/noparse]ReadADC]

ReadADC:
LOW ADC
SHIFTOUT DIO,CLK,MSBFIRST,[noparse][[/noparse]adcctrl\4]
SHIFTIN DIO,CLK,MSBPOST, [noparse][[/noparse]Sampval\12]
HIGH ADC
RETURN

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-01-12 20:54
    Graham-

    Suggestions:

    1. Take a closer look at the values the variable "add" will take
    during sampling.

    2. You must READ the values back from EEPROM into variable space in
    order to then SEROUT them.

    Regards,

    Steve
Sign In or Register to comment.