<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=4&amp;t=10500&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2015-02-04T17:56:06+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=10500&amp;mode</id>
<entry>
<author><name><![CDATA[Radzio M.]]></name></author>
<updated>2015-02-04T17:56:06+01:00</updated>
<published>2015-02-04T17:56:06+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117193#p117193</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117193#p117193"/>
<title type="html"><![CDATA[Re: FATFS ATMega32]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117193#p117193"><![CDATA[
Zmniejszyłem taktowanie lini z 14MHz na 7MHz i działa.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=396">Radzio M.</a> — 4 lut 2015, o 17:56</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Radzio M.]]></name></author>
<updated>2015-02-04T16:19:14+01:00</updated>
<published>2015-02-04T16:19:14+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117168#p117168</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117168#p117168"/>
<title type="html"><![CDATA[Re: FATFS ATMega32]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117168#p117168"><![CDATA[
<div class="quotetitle">majster napisał(a):</div><div class="quotecontent"><br />Tak ja używam FATFS na M128 i działa wyśmienicie.<br /></div><br />Możesz pokazać Twoją inicjalizację, ja coś mam problemy. Timera nie ruszałem, zmieniłem tylko ustawienia PORTB DDRB przy inicjalizacji.<br />[syntax=c]/*<br /> * main.c<br /> *<br /> *  Created on: 2015-02-04<br /> *       Autor: <br /> */<br /><br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#include &quot;MKUART0/mkuart0.h&quot;<br />#include &quot;MKUART1/mkuart1.h&quot;<br /><br />//#include &quot;uart.h&quot;<br />#include &quot;xitoa.h&quot;<br />#include &quot;FatFS/ff.h&quot;<br />#include &quot;FatFS/diskio.h&quot;<br />#include &quot;rtc.h&quot;<br /><br /><br /><br /><br />DWORD acc_size;/* Work register for fs command */<br />WORD acc_files, acc_dirs;<br />FILINFO Finfo;<br />#if _USE_LFN<br />char Lfname&#91;_MAX_LFN+1&#93;;<br />#endif<br /><br /><br />char Line&#91;128&#93;;/* Console input buffer */<br /><br />FATFS Fatfs&#91;_VOLUMES&#93;;/* File system object for each logical drive */<br />BYTE Buff&#91;256&#93;;/* Working buffer */<br /><br />volatile WORD Timer;/* 100Hz increment timer */<br /><br /><br /><br />#if _MULTI_PARTITION != 0<br />const PARTITION Drives&#91;&#93; = { {0,0}, {0,1} };<br />#endif<br /><br />/*---------------------------------------------------------*/<br />/* 100Hz timer interrupt generated by OC2                  */<br />/*---------------------------------------------------------*/<br /><br /><br />ISR(TIMER2_COMP_vect)<br />{<br />Timer++;/* Performance counter for this module */<br />disk_timerproc();/* Drive timer procedure of low level disk I/O module */<br />}<br /><br /><br /><br />/*---------------------------------------------------------*/<br />/* User Provided Timer Function for FatFs module           */<br />/*---------------------------------------------------------*/<br />/* This is a real time clock service to be called from     */<br />/* FatFs module. Any valid time must be returned even if   */<br />/* the system does not support a real time clock.          */<br />/* This is not required in read-only configuration.        */<br /><br /><br />DWORD get_fattime ()<br />{<br />RTC rtc;<br /><br /><br />/* Get local time */<br />//rtc_gettime(&amp;rtc);<br />rtc.year = 2010;<br />rtc.month = 10;<br />rtc.mday = 21;<br />rtc.hour = 17;<br />rtc.min = 45;<br />rtc.sec = 0;<br /><br /><br />/* Pack date and time into a DWORD variable */<br />return  ((DWORD)(rtc.year - 1980) &lt;&lt; 25)<br />| ((DWORD)rtc.month &lt;&lt; 21)<br />| ((DWORD)rtc.mday &lt;&lt; 16)<br />| ((DWORD)rtc.hour &lt;&lt; 11)<br />| ((DWORD)rtc.min &lt;&lt; 5)<br />| ((DWORD)rtc.sec &gt;&gt; 1);<br />}<br /><br /><br />/*--------------------------------------------------------------------------*/<br />/* Monitor                                                                  */<br /><br /><br />static<br />void put_dump (const BYTE *buff, DWORD ofs, BYTE cnt)<br />{<br />BYTE i;<br /><br /><br />xprintf(PSTR(&quot;%08lX &quot;), ofs);<br /><br />for(i = 0; i &lt; cnt; i++)<br />xprintf(PSTR(&quot; %02X&quot;), buff&#91;i&#93;);<br /><br />xputc(' ');<br />for(i = 0; i &lt; cnt; i++)<br />xputc((buff&#91;i&#93; &gt;= ' ' &amp;&amp; buff&#91;i&#93; &lt;= '~') ? buff&#91;i&#93; : '.');<br /><br />xputc('\n');<br />}<br /><br /><br />static<br />void get_line (char *buff, int len)<br />{<br />BYTE c;<br />int i = 0;<br /><br /><br />for (;;) {<br />c = uart_get();<br />if (c == '\r') break;<br />if ((c == '\b') &amp;&amp; i) {<br />i--;<br />uart_put(c);<br />continue;<br />}<br />if (c &gt;= ' ' &amp;&amp; i &lt; len - 1) {/* Visible chars */<br />buff&#91;i++&#93; = c;<br />xputc(c);<br />}<br />}<br />buff&#91;i&#93; = 0;<br />uart_put('\n');<br />}<br /><br /><br />static<br />FRESULT scan_files (<br />char* path/* Pointer to the working buffer with start path */<br />)<br />{<br />DIR dirs;<br />FRESULT res;<br />int i;<br />char *fn;<br /><br />res = f_opendir(&amp;dirs, path);<br />if (res == FR_OK) {<br />i = strlen(path);<br />while (((res = f_readdir(&amp;dirs, &amp;Finfo)) == FR_OK) &amp;&amp; Finfo.fname&#91;0&#93;) {<br />if (_FS_RPATH &amp;&amp; Finfo.fname&#91;0&#93; == '.') continue;<br />#if _USE_LFN<br />fn = *Finfo.lfname ? Finfo.lfname : Finfo.fname;<br />#else<br />fn = Finfo.fname;<br />#endif<br />if (Finfo.fattrib &amp; AM_DIR) {<br />acc_dirs++;<br />*(path+i) = '/'; strcpy(path+i+1, fn);<br />res = scan_files(path);<br />*(path+i) = '\0';<br />if (res != FR_OK) break;<br />} else {<br />//xprintf(PSTR(&quot;%s/%s\n&quot;), path, fn);<br />acc_files++;<br />acc_size += Finfo.fsize;<br />}<br />}<br />}<br /><br />return res;<br />}<br /><br /><br /><br />static<br />void put_rc (FRESULT rc)<br />{<br />const prog_char *p;<br />static const prog_char str&#91;&#93; =<br />&quot;OK\0&quot; &quot;DISK_ERR\0&quot; &quot;INT_ERR\0&quot; &quot;NOT_READY\0&quot; &quot;NO_FILE\0&quot; &quot;NO_PATH\0&quot;<br />&quot;INVALID_NAME\0&quot; &quot;DENIED\0&quot; &quot;EXIST\0&quot; &quot;INVALID_OBJECT\0&quot; &quot;WRITE_PROTECTED\0&quot;<br />&quot;INVALID_DRIVE\0&quot; &quot;NOT_ENABLED\0&quot; &quot;NO_FILE_SYSTEM\0&quot; &quot;MKFS_ABORTED\0&quot; &quot;TIMEOUT\0&quot;<br />&quot;LOCKED\0&quot; &quot;NOT_ENOUGH_CORE\0&quot; &quot;TOO_MANY_OPEN_FILES\0&quot;;<br />FRESULT i;<br /><br />for (p = str, i = 0; i != rc &amp;&amp; pgm_read_byte_near(p); i++) {<br />while(pgm_read_byte_near(p++));<br />}<br />xprintf(PSTR(&quot;rc=%u FR_%S\n&quot;), rc, p);<br />}<br /><br /><br /><br /><br />static<br />void IoInit ()<br />{<br />PORTA = 0b11111111;// Port A<br /><br />PORTB = 0b00000111; // Port B<br />DDRB  = 0b00001010;<br /><br />PORTC = 0b11111111;// Port C<br /><br />PORTD = 0b11111111; // Port D<br /><br /><br /><br /><br /><br />/*<br />OCR1A = 51;// Timer1: LCD bias generator (OC1B)<br />OCR1B = 51;<br />TCCR1A = 0b00010000;<br />TCCR1B = 0b00001010;<br />*/<br /><br />//atmega32<br />/* Timer2 – inicjalizacja przerwania co 10ms */<br />TCCR2 = (1&lt;&lt;WGM21);// tryb pracy CTC<br />TCCR2 = (1&lt;&lt;CS22)|(1&lt;&lt;CS21)|(1&lt;&lt;CS20);// preskaler = 1024<br />OCR2 = 143;// przerwanie porównania co 10ms (100Hz)<br />TIMSK = (1&lt;&lt;OCIE2);// Odblokowanie przerwania CompareMatch<br /><br /><br /><br /><br /><br />//rtc_init();// Initialize RTC<br /><br />sei();<br />}<br /><br /><br /><br /><br />int main(void)<br />{<br /><br />DDRC |= (1&lt;&lt;PC7);<br />PORTC |= (1&lt;&lt;PC7);<br /><br />char *ptr, *ptr2;<br />long p1, p2, p3;<br />BYTE res, b1, *bp;<br />WORD w1;<br />UINT s1, s2, cnt;<br />DWORD ofs, sect = 0;<br />const BYTE ft&#91;&#93; = {0,12,16,32};<br />RTC rtc;<br /><br />rtc.year = 2010;<br />rtc.month = 10;<br />rtc.mday = 21;<br />rtc.hour = 17;<br />rtc.min = 45;<br />rtc.sec = 0;<br /><br />FATFS *fs;<br />DIR dir;/* Directory object */<br />FIL file1, file2;/* File object */<br /><br />DSTATUS status;<br /><br /><br />IoInit();<br /><br /><br />USART0_Init(__UBRR1);<br />USART1_Init(__UBRR1);<br /><br /><br /><br />#define SCK PB1<br />#define MISO PB3  // definiujemy dodatkowy pin MISO<br />#define MOSI PB2<br />#define CS PB0<br /><br /><br />      DDRB |= (1&lt;&lt;CS)|(1&lt;&lt;MOSI)|(1&lt;&lt;SCK);<br />      PORTB |= (1&lt;&lt;CS);<br />      PORTB |= (1&lt;&lt;MISO); // podciągamy wejcie MISO do VCC<br /><br />      SPCR |= (1&lt;&lt;SPE)|(1&lt;&lt;MSTR);<br /><br /><br /><br /><br />      int i=0;<br /><br /><br />          disk_initialize(0);<br />          f_mount(0, &amp;Fatfs&#91;0&#93;)  ;<br />          for(;i&lt;10;i++){<br />          f_open(&amp;file1, &quot;test.txt&quot;, 2);<br />          f_lseek(&amp;file1,i*8);<br />          f_write(&amp;file1,&quot;HEHEHE\r\n&quot;,8,&amp;s1);<br />          f_close(&amp;file1);<br /><br />          }<br /><br />while(1){<br />//uart1_putc(uart1_getc());<br />}<br /><br /><br />return 0;<br />}[/syntax]<br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 4 minutach ]</span></strong><br /><br />Tzn. w timerku tylko rejestr porównania przestawiłem.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=396">Radzio M.</a> — 4 lut 2015, o 16:19</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Anonymous]]></name></author>
<updated>2015-02-04T14:43:14+01:00</updated>
<published>2015-02-04T14:43:14+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117146#p117146</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117146#p117146"/>
<title type="html"><![CDATA[Re: FATFS ATMega32]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117146#p117146"><![CDATA[
Pozwolę się wtrynić z pytaniem: po co ten <em>disk_initialize()</em> w kodzie?<br /><br />Cytat z opisu funkcji <em>disk_initialize()</em> na stronie projektu FatFS (<a href="http://elm-chan.org/fsw/ff/en/dinit.html"  class="postlink">klik</a>):<br /><div class="quotetitle">http://elm-chan.org napisał(a):</div><div class="quotecontent"><br />Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use f_mount() function instead. This function is called at volume mount process by FatFs module to manage the media change.<br /></div><p>Statystyki: Napisane przez Gość — 4 lut 2015, o 14:43</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[majster]]></name></author>
<updated>2015-02-04T14:08:39+01:00</updated>
<published>2015-02-04T14:08:39+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117139#p117139</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117139#p117139"/>
<title type="html"><![CDATA[Re: FATFS ATMega32]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117139#p117139"><![CDATA[
Tak ja używam FATFS na M128 i działa wyśmienicie.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1628">majster</a> — 4 lut 2015, o 14:08</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Radzio M.]]></name></author>
<updated>2015-02-04T13:35:27+01:00</updated>
<published>2015-02-04T13:35:27+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117138#p117138</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117138#p117138"/>
<title type="html"><![CDATA[Re: FATFS ATMega32]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117138#p117138"><![CDATA[
PRAWDA!<br />[syntax=c]disk_initialize(0);<br />      f_mount(0, &amp;Fatfs&#91;0&#93;)  ;<br />      for(;i&lt;10;i++){<br />      f_open(&amp;file1, &quot;test.txt&quot;, 2);<br />      f_lseek(&amp;file1,i*8);<br />      f_write(&amp;file1,&quot;HEHEHE\r\n&quot;,8,&amp;s1);<br />      f_close(&amp;file1);<br /><br />      }[/syntax]<br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 25 minutach ]</span></strong><br /><br />Zapytam jeszcze o to czy ktoś odpalił FATFS z BB na M128 eclipse luna atmel toolchain?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=396">Radzio M.</a> — 4 lut 2015, o 13:35</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[icer_cmg]]></name></author>
<updated>2015-02-04T13:19:27+01:00</updated>
<published>2015-02-04T13:19:27+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117136#p117136</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117136#p117136"/>
<title type="html"><![CDATA[Re: FATFS ATMega32]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117136#p117136"><![CDATA[
Myślę, że cały czas zaczynasz zapis od tego samego miejsca i nadpisujesz poprzedni zapis.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1636">icer_cmg</a> — 4 lut 2015, o 13:19</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Radzio M.]]></name></author>
<updated>2015-02-04T13:00:42+01:00</updated>
<published>2015-02-04T13:00:42+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117135#p117135</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117135#p117135"/>
<title type="html"><![CDATA[FATFS ATMega32]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=10500&amp;p=117135#p117135"><![CDATA[
Chcę 10 razy wpisać tekst do pliku <span style="color: #0000FF">&quot;HEHEHE\r\n&quot;</span>. W efekcie mam:<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">HEHEHE</div><br /><br />[syntax=c]int i=0;<br /><br /><br />      status = disk_initialize(0);<br />  if(status == FR_OK )<br />status =  f_mount(0, &amp;Fatfs&#91;0&#93;)  ;<br />if(status == FR_OK ) {<br /><br />for(;i&lt;10;i++){<br />status = f_open(&amp;file1, &quot;test.txt&quot;, 2);<br />if(status == FR_OK ){<br />f_write(&amp;file1,&quot;HEHEHE\r\n&quot;,8,&amp;s1);<br /><br />f_close(&amp;file1);<br />}<br />}<br />}<br /><br />      while(1);[/syntax]<br /><br />Co jest nie tak?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=396">Radzio M.</a> — 4 lut 2015, o 13:00</p><hr />
]]></content>
</entry>
</feed>