<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>zXc developments</title>
	<atom:link href="http://www.zxcdev.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zxcdev.com</link>
	<description>Enveloped by Code</description>
	<lastBuildDate>Fri, 05 Aug 2011 01:29:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Safe Interrupt Enable / Disable</title>
		<link>http://www.zxcdev.com/2010/05/safe-interrupt-enable-disable/</link>
		<comments>http://www.zxcdev.com/2010/05/safe-interrupt-enable-disable/#comments</comments>
		<pubDate>Mon, 24 May 2010 21:41:53 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Axiom]]></category>
		<category><![CDATA[HC12]]></category>

		<guid isPermaLink="false">http://www.zxcdev.com/?p=93</guid>
		<description><![CDATA[Having trouble switching from cooperative tasking? One of the easiest oversights is your &#8220;sei&#8221; and &#8220;cli&#8221; sections. The diagram below shows how you can run into problems within the critical sections of code. In this example when the memory allocation ends the interrupts are enabled with &#8220;cli&#8221; removing the critical section around the linked list [...]]]></description>
			<content:encoded><![CDATA[<p>Having trouble switching from cooperative tasking? One of the easiest oversights is your &#8220;sei&#8221; and &#8220;cli&#8221; sections.</p>
<p>The diagram below shows how you can run into problems within the critical sections of code. In this example when the memory allocation ends the interrupts are enabled with &#8220;cli&#8221; removing the critical section around the linked list manager. Once this happens RTI ISR fires and switches in thread 2. This example shows thread 2 popping an item from this list breaking the flow inside of thread 1.</p>
<p><a href="http://www.zxcdev.com/wp-content/uploads/2010/05/CriticalSectionError.png"><img src="http://www.zxcdev.com/wp-content/uploads/2010/05/CriticalSectionError.png" alt="" title="CriticalSectionError" width="450" height="512" class="aligncenter size-full wp-image-94" /></a></p>
<p><span id="more-93"></span><br />
To solve this problem we use a counting semaphore that allows us to keep track of the depth of the critical section.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> CriticalDepth <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> DisableInterrupts<span style="color: #009900;">&#40;</span> <span style="color: #993333;">void</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sei&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #339933;">++</span>CriticalDepth<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> EnableInterrupts<span style="color: #009900;">&#40;</span> bool force <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #339933;">--</span>CriticalDepth<span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> CriticalDepth <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">||</span> force <span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      CriticalDepth <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
      asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;cli&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2010/05/safe-interrupt-enable-disable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Threading</title>
		<link>http://www.zxcdev.com/2010/04/threading/</link>
		<comments>http://www.zxcdev.com/2010/04/threading/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 19:23:46 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Axiom]]></category>
		<category><![CDATA[HC12]]></category>

		<guid isPermaLink="false">http://www.zxcdev.com/?p=89</guid>
		<description><![CDATA[Threading allows functions to execute concurrently. The example below shows two threads switching between running and sleeping. As the RTI ISR executes it takes the current process off the schedule (list of processes) and switches in the next process on the schedule. Once all processes have been removed from the schedule the &#8220;Scheduler&#8221; steps in [...]]]></description>
			<content:encoded><![CDATA[<p>Threading allows functions to execute concurrently. The example below shows two threads switching between running and sleeping. As the RTI ISR executes it takes the current process off the schedule (list of processes) and switches in the next process on the schedule. Once all processes have been removed from the schedule the &#8220;Scheduler&#8221; steps in and creates a new schedule.</p>
<p><a href="http://www.zxcdev.com/wp-content/uploads/2010/04/ThreadSwitch.png"><img src="http://www.zxcdev.com/wp-content/uploads/2010/04/ThreadSwitch.png" alt="" title="ThreadSwitch" width="450" height="410" class="aligncenter size-full wp-image-99" /></a></p>
<p><span id="more-89"></span></p>
<p>Cooperative multitasking allows for threads to switch themselves out of processing during down time. Below is an example of this. If you find problems with the code please let me know with a comment.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">typedef</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> u8<span style="color: #339933;">;</span>
<span style="color: #993333;">typedef</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">short</span> u16<span style="color: #339933;">;</span>
<span style="color: #993333;">typedef</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> u32<span style="color: #339933;">;</span>
<span style="color: #993333;">typedef</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> size_t<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">#define THREADMAX 16</span>
<span style="color: #339933;">#define STACKSIZE 0x200</span>
&nbsp;
<span style="color: #993333;">void</span><span style="color: #339933;">*</span> threads<span style="color: #009900;">&#91;</span>THREADMAX<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> threadcount<span style="color: #339933;">;</span>
<span style="color: #993333;">void</span><span style="color: #339933;">*</span> _stackpointer<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> sStack
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//GCC Stack Vars</span>
    u16 xy<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Soft Register XY</span>
    u16 z<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Soft Register Z</span>
    u16 tmp<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Register Backup Pointer</span>
    u16 frame<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Frame Pointer</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//HC12 Stack Vars</span>
    u8 CCR<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Condition Code Register</span>
    u8 A<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Accumulator A</span>
    u8 B<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Accumulator B</span>
    u16 X<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Index Register X</span>
    u16 Y<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Index Register Y</span>
    u16 PC<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Program Counter (Starts at functions address)</span>
    u16 RS<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Return Service</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> Spawn<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #339933;">,</span> <span style="color: #993333;">void</span><span style="color: #339933;">*</span> callback<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">void</span><span style="color: #339933;">*</span> newstack <span style="color: #339933;">=</span> Allocate<span style="color: #009900;">&#40;</span>STACKSIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    sStack<span style="color: #339933;">*</span> sp <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>sStack<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>u16<span style="color: #009900;">&#41;</span>newstack <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>u16<span style="color: #009900;">&#41;</span>STACKSIZE <span style="color: #339933;">-</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>sStack<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    sp<span style="color: #339933;">-&gt;</span>xy <span style="color: #339933;">=</span> <span style="color: #208080;">0x0000</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>z <span style="color: #339933;">=</span> <span style="color: #208080;">0x0000</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>tmp <span style="color: #339933;">=</span> <span style="color: #208080;">0x0000</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>frame <span style="color: #339933;">=</span> <span style="color: #208080;">0x0000</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>CCR <span style="color: #339933;">=</span> <span style="color: #208080;">0xC0</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>A <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>B <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>X <span style="color: #339933;">=</span> <span style="color: #208080;">0x0000</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>Y <span style="color: #339933;">=</span> <span style="color: #208080;">0x0000</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>PC <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>u16<span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #339933;">;</span>
    sp<span style="color: #339933;">-&gt;</span>RS <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>u16<span style="color: #009900;">&#41;</span>callback<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> threadcount <span style="color: #339933;">&lt;</span> THREADMAX <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        threads<span style="color: #009900;">&#91;</span>threadcount<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sp<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #993333;">void</span> __attribute__<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>interrupt<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> Switch_RTI_ISR<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
    asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sei&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Set interrupt mask</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Save off the stack pointer</span>
    asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;LDX #_stackpointer&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;STS 0, X&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    threads<span style="color: #009900;">&#91;</span>current<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> _stackpointer<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Schedule the next thread</span>
    current <span style="color: #339933;">+=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    current <span style="color: #339933;">%=</span> threadcount<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Load the next stack pointer</span>
    _stackpointer <span style="color: #339933;">=</span> threads<span style="color: #009900;">&#91;</span>current<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;LDX #_stackpointer&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;LDS 0, X&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    CRGFLG <span style="color: #339933;">|=</span> <span style="color: #208080;">0x80</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Real Time Interrupt Flag </span>
    asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;cli&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Enable Interrupts</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//More of a bootloader that sets up variables</span>
<span style="color: #993333;">void</span> Main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span> 
    <span style="color: #666666; font-style: italic;">//Disable Interrupts</span>
    asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sei&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Spawn Threads</span>
    threadcount <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Init</span>
    Spawn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>Thread1<span style="color: #339933;">,</span> <span style="color: #208080;">0x4000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Spawn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>Thread2<span style="color: #339933;">,</span> <span style="color: #208080;">0x4000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Setup Thread Swap</span>
    <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">**</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #208080;">0x3FF0</span> <span style="color: #339933;">=</span> Swith_RTI_ISR<span style="color: #339933;">;</span>
    asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;cli&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;swi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> Thread1<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span> 
        Print<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Thread 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Pause<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;swi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> Thread2<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span> 
        Print<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Thread 2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Pause<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        asm <span style="color: #993333;">volatile</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;swi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2010/04/threading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Missing FFXI-Garuda?</title>
		<link>http://www.zxcdev.com/2010/04/missing-ffxi-garuda/</link>
		<comments>http://www.zxcdev.com/2010/04/missing-ffxi-garuda/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 22:08:51 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zxcdev.com/?p=85</guid>
		<description><![CDATA[If anyone is here looking for FFXI-Garuda.com post a comment and I&#8217;ll bring it back online.]]></description>
			<content:encoded><![CDATA[<p>If anyone is here looking for FFXI-Garuda.com post a comment and I&#8217;ll bring it back online.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2010/04/missing-ffxi-garuda/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hex Memory Dump</title>
		<link>http://www.zxcdev.com/2010/04/hex-memory-dump/</link>
		<comments>http://www.zxcdev.com/2010/04/hex-memory-dump/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 17:46:57 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zxcdev.com/?p=77</guid>
		<description><![CDATA[Here is a nice looking hex dump for those interested. ADDR &#124; B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF &#124; 0123456789ABCDEF =====&#124;==================================================&#124;================= 0000 &#124; FF D8 FF E0 00 10 4A 46 49 46 00 01 02 01 00 48 &#124; ......JFIF.....H 0010 &#124; 00 48 [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a nice looking hex dump for those interested.</p>
<pre>
ADDR | B0 B1 B2 B3 B4 B5 B6 B7  B8 B9 BA BB BC BD BE BF | 0123456789ABCDEF
=====|==================================================|=================
0000 | FF D8 FF E0 00 10 4A 46  49 46 00 01 02 01 00 48 | ......JFIF.....H
0010 | 00 48 00 00 FF ED 0A 96  50 68 6F 74 6F 73 68 6F | .H......Photosho
0020 | 70 20 33 2E 30 00 38 42  49 4D 04 04 07 43 61 70 | p 3.0.8BIM...Cap
</pre>
<p><span id="more-77"></span></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/******************************************************************************
  Hex Memory Dump
     Usage: Dump a block of memory to the display.
    Output: &amp;lt;0xMLOC&gt; | &lt;b0 -7&gt; &lt;b8 -15&gt; | &lt;c0 -7&gt;
******************************************************************************/</span>
<span style="color: #993333;">void</span> Memory_Dump<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span> block<span style="color: #339933;">,</span> size_t size<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">char</span> ASCII<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;0123456789ABCDEF&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
  PrintString<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Memory Dump of &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  PrintHex<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>block<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Trim the request to only high bytes</span>
  block <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #208080;">0xFFF0</span> <span style="color: #339933;">&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>block<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//If you the length was 0 display at least one line</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>size <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    size <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//For each location starting from the block and going the length  </span>
  PrintString<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>ADDR | B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF | 0123456789ABCDEF&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  PrintString<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>=====|==================================================|=================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> size <span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i <span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//Display the memory location in hex</span>
    PrintCharacter<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PrintHex<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>block<span style="color: #339933;">+</span>i<span style="color: #339933;">,</span> <span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PrintString<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; | &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Display the byte in hex</span>
    j <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;=</span> i <span style="color: #339933;">+</span> <span style="color: #208080;">0xF</span> <span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">//Take the location adds the offset remove the lower byte, shift it down and convert to ASCII</span>
      PrintCharacter<span style="color: #009900;">&#40;</span>ASCII<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>block<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>j<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;</span><span style="color: #208080;">0xF0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;&gt;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">//Take the location adds the offset remove the upper byte and convert to ASCII</span>
      PrintCharacter<span style="color: #009900;">&#40;</span>ASCII<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>block<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>j<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;</span><span style="color: #208080;">0x0F</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      PrintCharacter<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// After 8 bytes place a space for readability</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> j <span style="color: #339933;">==</span> i <span style="color: #339933;">+</span> <span style="color: #208080;">0x7</span> <span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>  
        PrintCharacter<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>    
&nbsp;
    <span style="color: #666666; font-style: italic;">//Display the char values of the location</span>
    PrintString<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;| &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    j <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> i <span style="color: #339933;">+</span> <span style="color: #208080;">0xF</span> <span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">//If the current is a backspace, return, or tab display a space</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>  <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>block<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #208080;">0x8</span> 
        <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>block<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0xD</span> <span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
        PrintCharacter<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">else</span>
      <span style="color: #009900;">&#123;</span>
        PrintCharacter<span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>block<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>j<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Increment the current location</span>
    i <span style="color: #339933;">+=</span> <span style="color: #208080;">0xF</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  PrintCharacter<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p></c0></b8></b0></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2010/04/hex-memory-dump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HC12 Read String or Char</title>
		<link>http://www.zxcdev.com/2010/04/hc12-read-string/</link>
		<comments>http://www.zxcdev.com/2010/04/hc12-read-string/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 23:40:02 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Axiom]]></category>
		<category><![CDATA[HC12]]></category>

		<guid isPermaLink="false">http://www.zxcdev.com/?p=51</guid>
		<description><![CDATA[Use this to read a string on the HC12. What this function does is check to see if there is an available character in the HC12&#8242;s Serial Communication Interface Port 0 Data Register. If you need to use this function with 9bit values the function needs to be adjusted to incorporate SC0DRH. Similarity if you [...]]]></description>
			<content:encoded><![CDATA[<p>Use this to read a string on the HC12. What this function does is check to see if there is an available character in the HC12&#8242;s Serial Communication Interface Port 0 Data Register. If you need to use this function with 9bit values the function needs to be adjusted to incorporate SC0DRH. Similarity if you would like to use Port 1 change SC0 to SC1.</p>
<p>UPDATE: I added the single char version because thats more basic.<br />
<span id="more-51"></span></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*******************************************
    Get Character
         Usage:    Get a character from the serial port
          Exit:    Returns the char from the input
*******************************************/</span>
<span style="color: #993333;">char</span> Read<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//Wait for the Receive Data Register Full Flag of SC0SR1</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SC0SR1 <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0x20</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//Yield or Wait        </span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Read the Data Register</span>
    <span style="color: #993333;">char</span> input <span style="color: #339933;">=</span> SC0DRL<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Echo</span>
    Print<span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Return value</span>
    <span style="color: #b1b100;">return</span> input<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">/*******************************************
  Get String
    Usage: Gets a string from the serial
    Enter: Buffer address and max buffer size.
     Exit: True on Overflow, False on Return Key
*******************************************/</span>
bool Read<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span> buffer<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> size<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> input <span style="color: #339933;">=</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> i <span style="color: #339933;">&lt;</span> size <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>        
        <span style="color: #666666; font-style: italic;">//Wait for the Receive Data Register Full Flag of SC0SR1</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SC0SR1 <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0x20</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//Yield or Wait        </span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Read the Data Register</span>
        input <span style="color: #339933;">=</span> SC0DRL<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> input <span style="color: #339933;">==</span> <span style="color: #208080;">0x08</span> <span style="color: #339933;">&amp;&amp;</span> i <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//Delete</span>
            buffer<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">--</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> input <span style="color: #339933;">==</span> <span style="color: #208080;">0x0D</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//Enter</span>
            buffer<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
            buffer<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> input<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #666666; font-style: italic;">//Echo</span>
        Print<span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2010/04/hc12-read-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ExtUSB AV Cable</title>
		<link>http://www.zxcdev.com/2010/01/extusb-av-cable/</link>
		<comments>http://www.zxcdev.com/2010/01/extusb-av-cable/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 10:56:15 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[HTC]]></category>
		<category><![CDATA[ExtUSB]]></category>

		<guid isPermaLink="false">http://zxcdev.com/?p=31</guid>
		<description><![CDATA[A &#8211; USB Ground B &#8211; +5V allows phone to suck 1000mA to charge faster C &#8211; +USB Data Line D &#8211; -USB Data Line E &#8211; +5V @ 1000mA (If you only have 500mA ground B) 1 &#8211; Video Out 2 &#8211; Audio Right 3 &#8211; Ground (Video Sense) 4 &#8211; No connection otherwise [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://zxcdev.com/wp-content/uploads/2010/01/20091219-ExtUSB.jpg"><img class="alignnone size-full wp-image-40" title="ExtUSB" src="http://zxcdev.com/wp-content/uploads/2010/01/20091219-ExtUSB.jpg" alt="HTC ExtUSB Connector" width="236" height="85" /></a></p>
<p>A &#8211; USB Ground<br />
B &#8211; +5V allows phone to suck 1000mA to charge faster<br />
C &#8211; +USB Data Line<br />
D &#8211; -USB Data Line<br />
E &#8211; +5V @ 1000mA (If you only have 500mA ground B)<br />
1 &#8211; Video Out<br />
2 &#8211; Audio Right<br />
3 &#8211; Ground (Video Sense)<br />
4 &#8211; No connection otherwise you loose video<br />
5 &#8211; Audio Ground<br />
6 &#8211; Audio Left<br />
Shield &#8211; Ground / Cable Shield</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2010/01/extusb-av-cable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MON12 Jump Table</title>
		<link>http://www.zxcdev.com/2009/12/mon12-jump-table/</link>
		<comments>http://www.zxcdev.com/2009/12/mon12-jump-table/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 20:54:41 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Axiom]]></category>
		<category><![CDATA[HC12]]></category>

		<guid isPermaLink="false">http://zxcdev.com/?p=29</guid>
		<description><![CDATA[This is the jump table from the CML12S-DP256 v2.7F. Use this if you want to access MON12 functionality inside of your programs. Command Address AUTO CB EB BR C8 EF BULK C9 AD ERASE C9 AD CALL CD 1E BF CA BB FILL CA BB EEMOD CA 5C GO CD 82 HELP CD 17 ? [...]]]></description>
			<content:encoded><![CDATA[<p>This is the jump table from the CML12S-DP256 v2.7F. Use this if you want to access MON12 functionality inside of your programs.</p>
<p><span id="more-29"></span></p>
<table border="0" cellspacing="0" cellpadding="4" align="center">
<tbody>
<tr>
<th>Command</th>
<th>Address</th>
</tr>
<tr>
<td>AUTO</td>
<td>CB EB</td>
</tr>
<tr>
<td>BR</td>
<td>C8 EF</td>
</tr>
<tr>
<td>BULK</td>
<td>C9 AD</td>
</tr>
<tr>
<td>ERASE</td>
<td>C9 AD</td>
</tr>
<tr>
<td>CALL</td>
<td>CD 1E</td>
</tr>
<tr>
<td>BF</td>
<td>CA BB</td>
</tr>
<tr>
<td>FILL</td>
<td>CA BB</td>
</tr>
<tr>
<td>EEMOD</td>
<td>CA 5C</td>
</tr>
<tr>
<td>GO</td>
<td>CD 82</td>
</tr>
<tr>
<td>HELP</td>
<td>CD 17</td>
</tr>
<tr>
<td>?</td>
<td>CD 17</td>
</tr>
<tr>
<td>LOAD</td>
<td>CF 19</td>
</tr>
<tr>
<td>MD</td>
<td>C9 B6</td>
</tr>
<tr>
<td>MM</td>
<td>CB 2E</td>
</tr>
<tr>
<td>MB</td>
<td>CB 2E</td>
</tr>
<tr>
<td>MW</td>
<td>CB 87</td>
</tr>
<tr>
<td>MOVE</td>
<td>CC 6F</td>
</tr>
<tr>
<td>COPY</td>
<td>CC 6F</td>
</tr>
<tr>
<td>NOAUTO</td>
<td>CC 26</td>
</tr>
<tr>
<td>OFFSET</td>
<td>D0 9B</td>
</tr>
<tr>
<td>P</td>
<td>CD 70</td>
</tr>
<tr>
<td>RD</td>
<td>C1 70</td>
</tr>
<tr>
<td>RM</td>
<td>D0 DF</td>
</tr>
<tr>
<td>STOPAT</td>
<td>CE 50</td>
</tr>
<tr>
<td>TRACE</td>
<td>CE 16</td>
</tr>
<tr>
<td>VERIFY</td>
<td>CF 12</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2009/12/mon12-jump-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HC12 Build you&#8217;r own Character</title>
		<link>http://www.zxcdev.com/2009/12/hc12-build-your-own-character/</link>
		<comments>http://www.zxcdev.com/2009/12/hc12-build-your-own-character/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 01:53:23 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Axiom]]></category>
		<category><![CDATA[HC12]]></category>

		<guid isPermaLink="false">http://zxcdev.com/?p=25</guid>
		<description><![CDATA[Using code from the manufacturer Axiom and several data sheets to figure out what they are talking about I finally found how to send your own character to the CGRAM (Character Generator RAM). This applies to the CML-9S12DP256 from Axiom with the add on LCD module (Fema CM204P-SGR1) running on a SPLC780D controller. Really the [...]]]></description>
			<content:encoded><![CDATA[<p>Using code from the manufacturer Axiom and several data sheets to figure out what they are talking about I finally found how to send your own character to the CGRAM (Character Generator RAM).</p>
<p><a href="http://zxcdev.com/wp-content/uploads/2009/12/8688065.jpg"><img class="alignnone size-medium wp-image-43" title="Space Invaders" src="http://zxcdev.com/wp-content/uploads/2009/12/8688065-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><span id="more-25"></span></p>
<p>This applies to the CML-9S12DP256 from Axiom with the add on LCD module (Fema CM204P-SGR1) running on a SPLC780D controller.</p>
<p>Really the application is quite simple all you need to do is send a command for the address of a CGRAM location.</p>
<p>Then send a string of characters to the string that describe the character that you want to generate.</p>
<p>Character Hex Array<br />
Each character has 5bits across starting from the right and 8 rows down.<br />
or from Left to Right, Top to Bottom</p>
<p>0bXXXXX<br />
0bXXXXX<br />
0bXXXXX<br />
0bXXXXX<br />
0bXXXXX<br />
0bXXXXX<br />
0bXXXXX<br />
0bXXXXX</p>
<p>Additional Characters</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">char</span> alien<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #208080;">0x16</span><span style="color: #339933;">,</span><span style="color: #208080;">0x0F</span><span style="color: #339933;">,</span><span style="color: #208080;">0x05</span><span style="color: #339933;">,</span><span style="color: #208080;">0x07</span><span style="color: #339933;">,</span><span style="color: #208080;">0x07</span><span style="color: #339933;">,</span><span style="color: #208080;">0x05</span><span style="color: #339933;">,</span><span style="color: #208080;">0x0F</span><span style="color: #339933;">,</span><span style="color: #208080;">0x16</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
SendCommand<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x40</span> <span style="color: #808080; font-style: italic;">/* +8 per Character */</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
SendString<span style="color: #009900;">&#40;</span>alien<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
SendCommand<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x80</span><span style="color: #009900;">&#41;</span>
SendCharacter<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x00</span> <span style="color: #808080; font-style: italic;">/* +1 per Character */</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2009/12/hc12-build-your-own-character/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Verilog RS Latch</title>
		<link>http://www.zxcdev.com/2009/12/verilog-rs-latch/</link>
		<comments>http://www.zxcdev.com/2009/12/verilog-rs-latch/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 18:50:01 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Verilog]]></category>

		<guid isPermaLink="false">http://zxcdev.com/?p=22</guid>
		<description><![CDATA[Quick example accomplishing an RS Latch with Verilog Data Flow. module rs_latch&#40; q, qn, s, r &#41;; &#160; input s, r; output q, qn; &#160; assign qn = ~&#40; s &#38; q &#41;; assign q = ~&#40; r &#38; qn &#41;; &#160; endmodule]]></description>
			<content:encoded><![CDATA[<p>Quick example accomplishing an RS Latch with Verilog Data Flow.<br />
<span id="more-22"></span></p>

<div class="wp_syntax"><div class="code"><pre class="verilog" style="font-family:monospace;"><span style="color: #A52A2A; font-weight: bold;">module</span> rs_latch<span style="color: #9F79EE;">&#40;</span> q<span style="color: #5D478B;">,</span> qn<span style="color: #5D478B;">,</span> s<span style="color: #5D478B;">,</span> r <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span>
&nbsp;
        <span style="color: #A52A2A; font-weight: bold;">input</span> s<span style="color: #5D478B;">,</span> r<span style="color: #5D478B;">;</span>
        <span style="color: #A52A2A; font-weight: bold;">output</span> q<span style="color: #5D478B;">,</span> qn<span style="color: #5D478B;">;</span>
&nbsp;
        <span style="color: #A52A2A; font-weight: bold;">assign</span> qn <span style="color: #5D478B;">=</span> <span style="color: #5D478B;">~</span><span style="color: #9F79EE;">&#40;</span> s <span style="color: #5D478B;">&amp;</span> q <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span>
        <span style="color: #A52A2A; font-weight: bold;">assign</span> q  <span style="color: #5D478B;">=</span> <span style="color: #5D478B;">~</span><span style="color: #9F79EE;">&#40;</span> r <span style="color: #5D478B;">&amp;</span> qn <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span>
&nbsp;
<span style="color: #A52A2A; font-weight: bold;">endmodule</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2009/12/verilog-rs-latch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Value to Hex String</title>
		<link>http://www.zxcdev.com/2009/08/value-to-hex-string/</link>
		<comments>http://www.zxcdev.com/2009/08/value-to-hex-string/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 01:50:12 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://zxcdev.com/?p=20</guid>
		<description><![CDATA[Ever needed to print out a hex string but needed a converter. Probably not because its build into most string classes. Though if you can&#8217;t use a string class then you might just need something like this. void ToHex( char character, char* buffer ) { char ASCII[] = "0123456789ABCDEF"; buffer[0] = ASCII[(character &#038; 0xF0)>>4]; buffer[1] [...]]]></description>
			<content:encoded><![CDATA[<p>Ever needed to print out a hex string but needed a converter. Probably not because its build into most string classes. Though if you can&#8217;t use a string class then you might just need something like this.<br />
<span id="more-20"></span></p>
<pre lang="C++">
void ToHex( char character, char* buffer )
{
        char ASCII[] = "0123456789ABCDEF";
        buffer[0] = ASCII[(character &#038; 0xF0)>>4];
        buffer[1] = ASCII[ character &#038; 0x0F];
        buffer[2] = '\0';
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2009/08/value-to-hex-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

