Tips and tricks

From MCS Wiki AVR
(Difference between revisions)
Jump to: navigation, search
(Created page with "This section describes tips and tricks received from users. <span style="font-family: Arial;"> </span> <span style="font-family: Arial;"> </span> Kyle Kronyak&nbs...")
 
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
This section describes tips and tricks received from users.
+
<span style="font-size: 14pt; font-weight: bold;">Tips & Tricks:</span>
  
<span style="font-family: Arial;">&nbsp;</span>
+
&nbsp;
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span class="f_Header">1. You can specify a binary number with the &B and you can use underscore "_" like:</span>
  
Kyle Kronyak&nbsp;: Using all the RAM from an external RAM chip.
+
<span class="f_Header">&nbsp;</span>
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;Var&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New';">Var&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">&</span><span style="font-family: 'Courier New';">B00_110000</span><br/><span style="font-family: 'Courier New';">Var&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">&</span><span style="font-family: 'Courier New';">B0000_1111</span><br/><span style="font-family: 'Courier New';">Var&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">&</span><span style="font-family: 'Courier New';">B00_11_00_11</span>
  
I have found a way to use the 607 bytes of external SRAM that are normally not available when using hardware SRAM support with BASCOM-AVR. It's actually quite simple. Basically the user just has to disconnect A15 from /CE on the SRAM module, and tie /CE to ground. This makes the chip enabled all the time. Addresses 1-32768 will then be available! The reason is because normally when going above 32768, the A15 pin would go high, disabling the chip. When A15 is not connected to /CE, the chip is always enabled, and allows the address number to "roll over". Therefore address 32162 is actually 0, 32163 is actually 1, 32164 is actually 2, etc. I have only tested this on a 32k SRAM chip. It definitely won't work on a 64k chip, and I believe it already works on any chip below 32k without modification of the circuit.
+
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span class="f_Header">2. How to use longer formulas:</span>
  
Programming problems
+
<span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;</span>
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;A&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;B&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;C&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-family: Courier;">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Now you want to use following formula: a = B / 4 + C</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' In Bascom you write</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New';">A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;B&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">/</span><span style="font-family: 'Courier New';">&nbsp;4</span><br/><span style="font-family: 'Courier New';">A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">+</span><span style="font-family: 'Courier New';">&nbsp;C</span>
  
- When you have unreliable results, use a shielded LPT cable
+
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 
 +
<span class="f_Header">3. You can use more than one Bascom statement in one line with colons ":"</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 
 +
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;A&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;B&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;C&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 11pt; font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Now you want to use following formula: a = B / 4 + C</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' In Bascom you write</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New';">A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;B&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">/</span><span style="font-family: 'Courier New';">&nbsp;4&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">:</span><span style="font-family: 'Courier New';">&nbsp;A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">+</span><span style="font-family: 'Courier New';">&nbsp;C</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
- The AVR chips have a bug, if the erase is not complete. It tend's to hang at some point. Sometimes although the system reports erased but blank check report "not empty". As per Atmel Data Errata You must drop the vcc by 0.5V ( a diode 1N4148 in Series ) if the erase is not happening. ( Such Chip's are unreliable and hence can be used only if you are sure ). This can happen after you have programmed the chip many times.
+
<span class="f_Header">4. You can use overlay to have easy access to the low byte and high byte of a WORD</span>
 +
 
 +
<span class="f_Header">(the same approach also work for e.g. LONG)</span>
 +
 
 +
&nbsp;
 +
 
 +
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;My_word&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Word</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;Low_byte&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">At</span><span style="font-family: 'Courier New';">&nbsp;My_word&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Overlay</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;High_byte&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">At</span><span style="font-family: 'Courier New';">&nbsp;My_word&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">+</span><span style="font-family: 'Courier New';">&nbsp;1&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Overlay</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New';">Low_byte&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">&</span><span style="font-family: 'Courier New';">B0000_1111</span><br/><span style="font-family: 'Courier New';">High_byte&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">&</span><span style="font-family: 'Courier New';">B1111_0000</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' This is how it will be stored in SRAM</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' &lt;-------my_word--------&gt;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' +-----------+----------+</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' | Low_byte &nbsp;|High_byte |</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' +-----------+----------+</span>
 +
 
 +
<span style="font-size: 11pt; font-family: 'Courier New'; color: rgb(0, 128, 0);">&nbsp;</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp;</span>
 +
 
 +
<span class="f_Header">5. To split a word into High byte and Low byte</span>&nbsp;you can also use&nbsp;&lt;a _fcknotitle="true" href="HIGH"&gt;HIGH&lt;/a&gt;&nbsp;and&nbsp;&lt;a _fcknotitle="true" href="LOW"&gt;LOW&lt;/a&gt;
 +
 
 +
&nbsp;
 +
 
 +
<span class="f_Header">6. Here is a way to print the content of a variable or AVR register:</span>
 +
 
 +
&nbsp;
 +
 
 +
Use&nbsp;<span style="font-size: 11pt; font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 11pt; font-family: 'Courier New';">&nbsp;</span><span style="font-size: 11pt; font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Bin</span><span style="font-size: 11pt; font-family: 'Courier New'; color: rgb(255, 0, 0);">(X)</span>
 +
 
 +
&nbsp;
 +
 
 +
Example:
 +
 
 +
&nbsp;
 +
 
 +
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"m88def.dat"</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' we use the M88</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;8000000</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$baud</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;19200</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;32</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;8</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;24</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;A&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New';">A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">&</span><span style="font-family: 'Courier New';">B00000001</span><br/><span style="font-family: 'Courier New';">A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;A&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">*</span><span style="font-family: 'Courier New';">&nbsp;2</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Bin</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'Courier New';">a</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">) &nbsp; &nbsp; &nbsp;&nbsp;</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' end program</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp;</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp;</span>
 +
 
 +
<span class="f_Header">7. If you do not want that Bascom-AVR is sending Carriage + &nbsp;Return after a print command use semi-colon ";" &nbsp;after the print funtion:</span>
 +
 
 +
&nbsp;
 +
 
 +
Example:
 +
 
 +
&nbsp;
 +
 
 +
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"m88def.dat"</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' specify the used micro</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;8000000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' used crystal frequency</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$baud</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;19200 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' use baud rate</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' default use 32 for the hardware stack</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' default use 10 for the SW stack</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;40 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' default use 40 for the frame space</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;Com1&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;Dummy&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;Synchrone&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;0&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;Parity&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;None&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;Stopbits&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;1&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;Databits&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;8&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;Clockpol&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;0</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Hello World"</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">;</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span>
 +
 
 +
<span style="font-size: 11pt; font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">&nbsp;</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp;</span>
 +
 
 +
<span class="f_Header">8. For the user who want to use external editors:</span>
 +
 
 +
&nbsp;
 +
 
 +
The&nbsp;<span style="font-weight: bold;">bascomp.exe</span>&nbsp;has been updated. It can be downloaded from the download section.
 +
 
 +
&nbsp;
 +
 
 +
It now supports a simpler way to be called.
 +
 
 +
&nbsp;
 +
 
 +
The utility has been updated and now will retrieve all info from the source file, but only when your main program contains these directive&nbsp;:
 +
 
 +
$regfile, $hwstack, $swstack, $framesize
 +
 
 +
&nbsp;
 +
 
 +
<span style="font-weight: bold;">Example&nbsp;:</span>
 +
 
 +
bascomp.exe "c:\my folder\source\sample.bas" auto
 +
 
 +
&nbsp;
 +
 
 +
The 'auto' is a switch so the utility will retrieve the settings from your code.
 +
 
 +
&nbsp;
 +
 
 +
<span class="f_Header">9. You can use $initmicro if you want to run special tasks at startup:</span>
 +
 
 +
See&nbsp;&lt;a _fcknotitle="true" href="%24INITMICRO"&gt;$INITMICRO&lt;/a&gt;
 +
 
 +
&nbsp;
 +
 
 +
<span class="f_Header">10. You can use $include&nbsp;</span><span class="f_Header">to make larger projects better readable</span>: See&nbsp;<span style="font-size: 12pt; font-family: 'Times New Roman';">&lt;a _fcknotitle="true" href="%24INCLUDE"&gt;$INCLUDE&lt;/a&gt;</span>
 +
 
 +
&nbsp;
 +
 
 +
<span class="f_Header">11. Your LCD is not working and you need a list of steps what do check:</span>
 +
 
 +
&nbsp;
 +
 
 +
a. Check fuse bit settings
 +
 
 +
b. Are the AVR pins are OK&nbsp;?
 +
 
 +
&nbsp;
 +
 
 +
To test the AVR pins you can do following:
 +
 
 +
Write a program that toggles all the lcd pins and then measure the logic level.
 +
 
 +
Then check with a DVM or led-series resistor if all pins change level. if they do, there is a problem with the lcd
 +
 
 +
&nbsp;
 +
 
 +
If the pin do not toggle:
 +
 
 +
- pin defect
 +
 
 +
- track or solder problem.
 +
 
 +
&nbsp;
 +
 
 +
Here the test program:
 +
 
 +
&nbsp;
 +
 
 +
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"m328pdef.dat"</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Specify The Used Micro</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;16000000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' used crystal frequency</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$baud</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;19200 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' use baud rate</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' default use 32 for thehardware stack</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' default use 10 for theSW stack</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;40 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' default use 40 for theframe space</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;Clockdiv&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' divide xtal clock by 1, default fuse bit is set &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' to 8 by elektor</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portc</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">3&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' RW</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portd</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">4&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Db4</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portd</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">5&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Db5</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portd</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">6&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Db6</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portd</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">6&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Db7</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portc</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">1&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' E</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portc</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">2&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' RS</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">do</span><br/><span style="font-family: 'Courier New';">&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">toggle</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">portc</span><br/><span style="font-family: 'Courier New';">&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">toggle</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">portd</span><br/><span style="font-family: 'Courier New';">&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">waitms</span><span style="font-family: 'Courier New';">&nbsp;1000</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Loop</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-size: 11pt; font-family: 'Courier New';">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-size: 11pt; font-family: 'Courier New'; color: rgb(0, 128, 0);">' end program</span>
 +
 
 +
&nbsp;
 +
 
 +
&nbsp;
 +
 
 +
<span class="f_Header">12. With the Lib Manager you can compile a Library (*.lib) into an *.lbx file.</span>
 +
 
 +
See here:&nbsp;&lt;a href="Tools%20LIB%20Manager"&gt;Tools LIB Manager&lt;/a&gt;
 +
 
 +
&nbsp;
 +
 
 +
&nbsp;
 +
 
 +
<span class="f_Header">13. There is a timeout function for hardware and software UART</span>
 +
 
 +
See&nbsp;&lt;a _fcknotitle="true" href="%24TIMEOUT"&gt;$TIMEOUT&lt;/a&gt;
 +
 
 +
&nbsp;
 +
 
 +
&nbsp;
 +
 
 +
<span class="f_Header">14. How to use the Powerdown function:</span>
 +
 
 +
See also:&nbsp;&lt;a href="CONFIG%20POWERMODE"&gt;CONFIG POWERMODE&lt;/a&gt;
 +
 
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 
 +
If you can not measure the same power down current as written in the data sheet you also need to use a
 +
 
 +
Low Quiescent Current LDO Regulator to meet that specs (if you measure the current including the Current LDO Regulator).
 +
 
 +
&nbsp;
 +
 
 +
Examples for 3.3Volt Low Quiescent Current LDO Regulator&nbsp;:
 +
<div style="padding: 0px; margin: 0px 0px 0px 24px;">
 +
{| border="0" cellpadding="0" cellspacing="0"
 +
|- valign="baseline" style="vertical-align: baseline;"
 +
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 +
| MCP1702 --> typical 2µA
 +
|}
 +
</div><div style="padding: 0px; margin: 0px 0px 0px 24px;">
 +
{| border="0" cellpadding="0" cellspacing="0"
 +
|- valign="baseline" style="vertical-align: baseline;"
 +
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 +
| MCP1700 --> typical 1.6µA
 +
|}
 +
</div><div style="padding: 0px; margin: 0px 0px 0px 24px;">
 +
{| border="0" cellpadding="0" cellspacing="0"
 +
|- valign="baseline" style="vertical-align: baseline;"
 +
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 +
| AS1375 low power LDO --> 1µA (typ.) of quiescent current
 +
|}
 +
</div><div style="padding: 0px; margin: 0px 0px 0px 24px;">
 +
{| border="0" cellpadding="0" cellspacing="0"
 +
|- valign="baseline" style="vertical-align: baseline;"
 +
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 +
| TPS78233 3,3V --> 0.4µA
 +
|}
 +
</div>
 +
&nbsp;<br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Using the new config powermode = PowerDown function with ATTINY13</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Used Bascom-AVR Version 2.0.7.3</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Fuse Bits:</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Disable DWEN (Debug Wire) Fuse Bit</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Disable Brown-Out Detection in Fuse Bits</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Disable Watchdog in Fuse Bits</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' You can also just use &nbsp;Config Powermode = Powerdown</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' But this example here also considers what the data sheet write under "MINIMIZING POWER CONSUMPTION"</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' You need to follow this when you want to achieve the current consumption which you find in the</span>
 +
 
 +
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' data sheet under Powerdown Mode.</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 1. Disable/Switch off ADC</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 2. Disable/Switch off Analog Comparator</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 3. Disable Brown-out Detection when not needed</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 4. Disable internal voltage reference</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 5. Disable Watchdog Timer when not needed</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 6. Disable the digital input buffer</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 7. Enable Pull-up or pull-down an all unused pins</span><br/><span style="font-size: 11pt; font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"attiny13.dat"</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;9600000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 9.6MHz</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;10</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;0</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;24</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">On</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Int0</span><span style="font-family: 'Courier New';">&nbsp;Int0_isr &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' INT0 will be the wake-up source for Powerdown Mode</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Int0</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Low</span><span style="font-family: 'Courier New';">&nbsp;Level</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Int0</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Prepare Powerdown:</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' To minimize power consumption, enable pull-up or -down on all unused pins, and</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' disable the digital input buffer on pins that are connected to analog sources</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">0&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">0</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">1&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' INT0 --> external 47K pull-up</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Set Portb.1</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">2&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">2</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">3&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">3</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">4&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">4</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portb</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">5&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' External Pull-Up (Reset)</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Didr0</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Bits</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">ain1d</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Ain0d</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Disable digital input buffer on the AIN1/0 pin</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Acsr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">acd</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Switch off &nbsp;the power to the Analog Comparator</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' alternative:</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Stop Ac</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Reset</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Acsr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">acbg</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Disable Analog Comparator Bandgap Select</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Reset</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Adcsra</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">aden</span><span style="font-family: 'Courier New';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Switch off ADC</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' alternative:</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Stop Adc</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'###############################################################################</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Do</span><br/>&nbsp; &nbsp; &nbsp; &nbsp;<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Wait</span><span style="font-family: 'Courier New';">&nbsp;3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' now we have 3 second to measure the Supply Current</span>
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' in Active Mode</span><br/><span style="font-family: 'Courier New';">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Interrupts</span><br/><span style="font-family: 'Courier New';">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Now call Powerdown function</span><br/><span style="font-family: 'Courier New';">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;Powermode&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Powerdown</span>
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp;<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Here you have time to measure PowerDown current consumption until a Low Level</span>
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp;<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' on Portb.1 which is the PowerDown wake-up</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Loop</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'###############################################################################</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span><br/><span style="font-family: 'Courier New';">&nbsp;</span><br/><span style="font-family: 'Courier New';">Int0_isr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">:</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' wake_up</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Return</span>
 +
 
 +
 
  
<br/><br/>{{Languages}}
+
{{Languages}}
  
[[Category:BASCOM Language Fundamentals]]
+
[[Category:BASCOM_Language_Fundamentals]]

Latest revision as of 21:22, 24 August 2013

Tips & Tricks:

 

1. You can specify a binary number with the &B and you can use underscore "_" like:

 

Dim Var As Byte
 
Var = &B00_110000
Var = &B0000_1111
Var = &B00_11_00_11

 

 

2. How to use longer formulas:

 

Dim A As Byte
Dim B As Byte
Dim C As Byte
 
' Now you want to use following formula: a = B / 4 + C
' In Bascom you write
 
= B / 4
= A + C

 

 

3. You can use more than one Bascom statement in one line with colons ":"

 

Dim A As Byte
Dim B As Byte
Dim C As Byte
 
' Now you want to use following formula: a = B / 4 + C
' In Bascom you write
 
= B / 4 : A = A + C

 

4. You can use overlay to have easy access to the low byte and high byte of a WORD

(the same approach also work for e.g. LONG)

 

Dim My_word As Word
Dim Low_byte As Byte At My_word Overlay
Dim High_byte As Byte At My_word + 1 Overlay
 
Low_byte = &B0000_1111
High_byte = &B1111_0000
 
' This is how it will be stored in SRAM
' <-------my_word-------->
' +-----------+----------+
' | Low_byte  |High_byte |
' +-----------+----------+

 

 

5. To split a word into High byte and Low byte you can also use <a _fcknotitle="true" href="HIGH">HIGH</a> and <a _fcknotitle="true" href="LOW">LOW</a>

 

6. Here is a way to print the content of a variable or AVR register:

 

Use Print Bin(X)

 

Example:

 

$regfile = "m88def.dat"                                        ' we use the M88
$crystal = 8000000
$baud = 19200
$hwstack = 32
$swstack = 8
$framesize = 24
 
 
Dim A As Byte
 
= &B00000001
= A * 2
Print Bin(a)       
 
End                                                              ' end program

 

 

7. If you do not want that Bascom-AVR is sending Carriage +  Return after a print command use semi-colon ";"  after the print funtion:

 

Example:

 

$regfile = "m88def.dat"                                            ' specify the used micro
$crystal = 8000000                                              ' used crystal frequency
$baud = 19200                                                    ' use baud rate
$hwstack = 32                                                    ' default use 32 for the hardware stack
$swstack = 10                                                    ' default use 10 for the SW stack
$framesize = 40                                                  ' default use 40 for the frame space
 
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
 
Print "Hello World" ;
 
End

 

 

8. For the user who want to use external editors:

 

The bascomp.exe has been updated. It can be downloaded from the download section.

 

It now supports a simpler way to be called.

 

The utility has been updated and now will retrieve all info from the source file, but only when your main program contains these directive :

$regfile, $hwstack, $swstack, $framesize

 

Example :

bascomp.exe "c:\my folder\source\sample.bas" auto

 

The 'auto' is a switch so the utility will retrieve the settings from your code.

 

9. You can use $initmicro if you want to run special tasks at startup:

See <a _fcknotitle="true" href="%24INITMICRO">$INITMICRO</a>

 

10. You can use $include to make larger projects better readable: See <a _fcknotitle="true" href="%24INCLUDE">$INCLUDE</a>

 

11. Your LCD is not working and you need a list of steps what do check:

 

a. Check fuse bit settings

b. Are the AVR pins are OK ?

 

To test the AVR pins you can do following:

Write a program that toggles all the lcd pins and then measure the logic level.

Then check with a DVM or led-series resistor if all pins change level. if they do, there is a problem with the lcd

 

If the pin do not toggle:

- pin defect

- track or solder problem.

 

Here the test program:

 

$regfile = "m328pdef.dat"                                  ' Specify The Used Micro
$crystal = 16000000                                          ' used crystal frequency
$baud = 19200                                                ' use baud rate
$hwstack = 32                                                ' default use 32 for thehardware stack
$swstack = 10                                                ' default use 10 for theSW stack
$framesize = 40                                              ' default use 40 for theframe space
 
Config Clockdiv = 1                                          ' divide xtal clock by 1, default fuse bit is set                                                                                                ' to 8 by elektor
 
Config Portc.= Output                                      ' RW
Config Portd.= Output                                      ' Db4
Config Portd.= Output                                      ' Db5
Config Portd.= Output                                      ' Db6
Config Portd.= Output                                      ' Db7
Config Portc.= Output                                      ' E
Config Portc.= Output                                      ' RS
 
do
  toggle portc
  toggle portd
  waitms 1000
Loop
 
End                                                    ' end program

 

 

12. With the Lib Manager you can compile a Library (*.lib) into an *.lbx file.

See here: <a href="Tools%20LIB%20Manager">Tools LIB Manager</a>

 

 

13. There is a timeout function for hardware and software UART

See <a _fcknotitle="true" href="%24TIMEOUT">$TIMEOUT</a>

 

 

14. How to use the Powerdown function:

See also: <a href="CONFIG%20POWERMODE">CONFIG POWERMODE</a>

 

If you can not measure the same power down current as written in the data sheet you also need to use a

Low Quiescent Current LDO Regulator to meet that specs (if you measure the current including the Current LDO Regulator).

 

Examples for 3.3Volt Low Quiescent Current LDO Regulator :

MCP1702 --> typical 2µA
MCP1700 --> typical 1.6µA
AS1375 low power LDO --> 1µA (typ.) of quiescent current
TPS78233 3,3V --> 0.4µA

 
' Using the new config powermode = PowerDown function with ATTINY13
 
' Used Bascom-AVR Version 2.0.7.3
 
' Fuse Bits:
' Disable DWEN (Debug Wire) Fuse Bit
' Disable Brown-Out Detection in Fuse Bits
' Disable Watchdog in Fuse Bits
 
' You can also just use  Config Powermode = Powerdown
 
' But this example here also considers what the data sheet write under "MINIMIZING POWER CONSUMPTION"
' You need to follow this when you want to achieve the current consumption which you find in the

' data sheet under Powerdown Mode.
 
' 1. Disable/Switch off ADC
' 2. Disable/Switch off Analog Comparator
' 3. Disable Brown-out Detection when not needed
' 4. Disable internal voltage reference
' 5. Disable Watchdog Timer when not needed
' 6. Disable the digital input buffer
' 7. Enable Pull-up or pull-down an all unused pins
 
$regfile = "attiny13.dat"
$crystal = 9600000                                      ' 9.6MHz
$hwstack = 10
$swstack = 0
$framesize = 24
 
On Int0 Int0_isr                                          ' INT0 will be the wake-up source for Powerdown Mode
Config Int0 = Low Level
Enable Int0
 
' Prepare Powerdown:
' To minimize power consumption, enable pull-up or -down on all unused pins, and
' disable the digital input buffer on pins that are connected to analog sources
Config Portb.= Input
Set Portb.0
Config Portb.= Input                                    ' INT0 --> external 47K pull-up
'Set Portb.1
Config Portb.= Input
Set Portb.2
Config Portb.= Input
Set Portb.3
Config Portb.= Input
Set Portb.4
Config Portb.= Input                                    ' External Pull-Up (Reset)
 
Didr0 = Bits(ain1d , Ain0d)                              ' Disable digital input buffer on the AIN1/0 pin
 
Set Acsr.acd                                              ' Switch off  the power to the Analog Comparator
' alternative:
' Stop Ac
 
Reset Acsr.acbg                                          ' Disable Analog Comparator Bandgap Select
 
Reset Adcsra.aden                                      ' Switch off ADC
' alternative:
' Stop Adc
 
'###############################################################################
Do
       Wait 3                                                ' now we have 3 second to measure the Supply Current

                                                                       ' in Active Mode
         Enable Interrupts
         ' Now call Powerdown function
         Config Powermode = Powerdown

       ' Here you have time to measure PowerDown current consumption until a Low Level

       ' on Portb.1 which is the PowerDown wake-up
Loop
'###############################################################################
End
 
Int0_isr:
' wake_up
Return


Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language