Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20695

BASCOM-AVR : WRITE VARIABLE TO FLASH MEMORY OF MICROCONTROLLER : REPLY

$
0
0
Hi, -Your using the software i2c, better use the hardware i2s (twi) it's faster. (you must change your hardware then) See http://avrhelp.mcselec.com/config_twi.htm -Your waiting after every write 5ms, that's also not really needed. Most of the eeproms writing faster then described in the datasheet. To be sure that the data is written and also to be sure that your not waiting to long for nothing you can do ACK polling, look at this: [code:1:4acaf753c3] Writeeepromserial: I2cstart I2cwbyte Eewrite I2cwbyte Highaddress I2cwbyte Lowaddress I2crbyte Highintvar I2crbyte Lowintvar I2cstop Do 'To replace the waitms5 by polling for ACK I2cstart 'generate start I2cwbyte Eewrite 'slave adsress I2cstop Loop Until Err = 0 Return [/code:1:4acaf753c3] -Also writing a complete page to the eeprom will speed up writing. -In your test loop your printing some things, this also consumes some time. -Splitting ADDRESS up in high and low bytes can be done faster with the overlay function, same with J (see this nice tutorial from MAK3 about overlay http://mcselec.com/index.php?option=com_content&task=view&id=307&Itemid=57 ) [code:1:4acaf753c3] Dim Address As Word Dim Lowaddress As Byte At Address Overlay Dim Highaddress As Byte At Address + 1 Overlay Dim J As Integer Dim Lowintvar As Byte At J Overlay Dim Highintvar As Byte At J + 1 Overlay 'You can reduce the first part of the main loop then to this J = -30500 For I = 0 To 50 J = J + I 'Print #1 , J Address = I Print #1 , J 'Print #1 , I 'Print #1 , Highintvar 'Print #1 , Lowintvar 'Print #1 , "------" Gosub Writeeepromserial Toggle Tester Next I [/code:1:4acaf753c3] -You toggle TESTER pin, so it takes 2 loops to go from low to high to low, don't forget that.

Viewing all articles
Browse latest Browse all 20695

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>