PDA

View Full Version : help with how PIC stores values



longpole001
- 17th February 2012, 11:52
Hi just starting out using pic basic pro and PICs in general and have some basic questions on writing and reading the values into eeprom PIC (12F683) if someone can give some input

i wish to write the captured measured values of pulsin directly to the pic for IR code (32 bits) on a pic running internal at 4mhz and generate the same pulse streem out with the correct timing from the stored values

if a value of say 150 is recieved - then this would be 150 x 10us = 1.5ms pulse i believe

using the following code would values stored higher than 255 be read back correctly ? , if not what coding would

regards




Leader VAR WORD ' will be up to 900 for a 9mS leader pulseBtnVal VAR BYTE[32] ' holds 32 pulse results



FOR X = 0 TO 31 ' grab 32 incoming pulses
PULSIN GPIO.0,1,BtnVal(X) ' now measuring high-going pulse widths
NEXT X

x = 0

for x = 0 to 31 ' store timed values in pic
write x , BtnVal(X)
pause 1000 ' wait 10ms before writing next value - not sure if required will reduce / remove after testing
next X

longpole001
- 18th February 2012, 11:08
any input guys ???

Dave
- 19th February 2012, 00:50
well, if you only have the variable sized as a byte, you cnt have a value bigger thn 255. However, if you have a word sized variable then you would store the upper byte to a single storage element then, store the lower byte to the next proceeding storage element. You would just read the upper byte and then the lower byte into a word sized variable when ready to read it from memory.

longpole001
- 20th February 2012, 03:52
ok thanks will do some playing