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

Share your working BASCOM-AVR code here : RTC PCF8583 read Function and write Soubroutine : NEWTOPIC

$
0
0
Hi, people of good will, I am excited over new features of new version of Bascom. Now we can write subrotines and functions totaly indipendent from main program in to link them together into working program. As first example i rewrite my old subroutines to read and write PCF8583 RTC for this new version. Attached file contains them. Instructions, how to use them, are in the file itself. Attached file pcf8583.inc.txt should be renamed to pcf8583.inc before use. Here is an example of main program using them: [code:1:7ee27c4869]Const Program = "RTC" $regfile = "m644pdef.dat" $crystal = 11059200 $baud = 19200 $hwstack = 384 $swstack = 128 $framesize = 128 Config Submode = New ' must ! $include Pcf8583.inc ' must ! Open "comb.4:9600,8,n,1" For Output As #2 ' UART for monitoring ' I2C ' RTC PCF8583 ' ============= Config Sda = Portd.7 ' mandatory, depending on shematic Config Scl = Portd.5 Const Wrtc = &HA0 ' mandatory, depending on address pin of RTC Const Rrtc = &HA1 ' Let us provide some date and time to be written in RTC ' for example: Monday, 2. April 2013 at 2013 Hours Dim Wrkstr As String * 32 Wrkstr = "020413 2013 Mo" Print #2 , Wrkstr ; " Data written." ' call write RTC subroutine and submit date and time: Wpcf8583sub Wrkstr Do ' call read RTC function and print result Print #2 , Rpcf8583fun() ; " Data read." Wait 2 Loop End Close #2 [/code:1:7ee27c4869] And printout shall be like this: [quote:7ee27c4869]020413 2013 Mo Data written. 020413 2013 Mo Data read. 020413 2013 Mo Data read. 020413 2013 Mo Data read. 020413 2013 Mo Data read.[/quote:7ee27c4869]

Viewing all articles
Browse latest Browse all 20563

Trending Articles



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