<?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>PSoC Creator &#8211; IoT Expert</title>
	<atom:link href="https://iotexpert.com/category/tools/psoc-creator/feed/" rel="self" type="application/rss+xml" />
	<link>https://iotexpert.com</link>
	<description>Engineering for the Internet of Things</description>
	<lastBuildDate>Sun, 21 Oct 2018 13:06:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://iotexpert.com/wp-content/uploads/2017/01/cropped-Avatar-32x32.jpg</url>
	<title>PSoC Creator &#8211; IoT Expert</title>
	<link>https://iotexpert.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Mouser Video Training Workshop &#8211; October 24</title>
		<link>https://iotexpert.com/mouser-video-training-workshop-october-24/</link>
					<comments>https://iotexpert.com/mouser-video-training-workshop-october-24/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Fri, 19 Oct 2018 15:14:10 +0000</pubDate>
				<category><![CDATA[4343W]]></category>
		<category><![CDATA[CY8CKIT-062-WiFi-BT]]></category>
		<category><![CDATA[Mouser 10-24-18 PSoC 6 & 4343W WiFi/BLE]]></category>
		<category><![CDATA[PSoC 6]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[WICED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=5895</guid>

					<description><![CDATA[On October 24, I will be teaching a Mouser video training workshop &#8230; live streaming on the internet.  The workshop will be about PSoC, WICED, WiFi and Bluetooth.  I am going to show PSoC Creator, WICED Studio and Cypress&#8217;s new development tool Modus Toolbox. You can register for the workshop at this link. I am [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>On October 24, I will be teaching a <a href="http://mouser.com" target="_blank" rel="noopener">Mouser</a> video training workshop &#8230; live streaming on the internet.  The workshop will be about PSoC, WICED, WiFi and Bluetooth.  I am going to show PSoC Creator, WICED Studio and Cypress&#8217;s new development tool Modus Toolbox.</p>
<p>You can register for the workshop at this <a href="https://www.electronicdesign.com/webcasts/designing-low-power-cloud-connected-iot-devices-psoc-6-mcu-s-and-wiced-wi-fibluetooth?partnerref=Mouser" target="_blank" rel="noopener">link</a>.</p>
<p>I am going to build the whole class around the <a href="http://www.cypress.com/documentation/development-kitsboards/psoc-6-wifi-bt-pioneer-kit" target="_blank" rel="noopener">CY8CKIT-062-BLE-WiFi</a> Development Kit.  You can get the devlopment kit from <a href="https://www.mouser.com/ProductDetail/Cypress-Semiconductor/CY8CKIT-062-WIFI-BT?qs=lYGu3FyN48c6Xy1GM0bmkg%3D%3D" target="_blank" rel="noopener">Mouser</a>.</p>
<p><a href="https://iotexpert.com/2018/10/19/mouser-video-training-workshop-october-24/img_6353/" rel="attachment wp-att-5899"><img fetchpriority="high" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/IMG_6353-e1539961924645-1024x768.jpg" alt="" width="1024" height="768" class="alignnone wp-image-5899 size-large" srcset="https://iotexpert.com/wp-content/uploads/2018/10/IMG_6353-e1539961924645-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2018/10/IMG_6353-e1539961924645-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/10/IMG_6353-e1539961924645-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/10/IMG_6353-e1539961924645-768x576.jpg 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is the introduction:</p>
<div class="jupiterx-oembed"><iframe title="Mouser Video Workshop PSoC" width="500" height="281" src="https://www.youtube.com/embed/30NgWBwbu5w?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-video-training-workshop-october-24/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The Lost Art of Assembly Language Programming</title>
		<link>https://iotexpert.com/lost-art-assembly-language-programming/</link>
					<comments>https://iotexpert.com/lost-art-assembly-language-programming/#comments</comments>
		
		<dc:creator><![CDATA[Darrin Vallis]]></dc:creator>
		<pubDate>Fri, 09 Feb 2018 19:53:37 +0000</pubDate>
				<category><![CDATA[CY8CKIT-042]]></category>
		<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[Cy8CKIT-145]]></category>
		<category><![CDATA[Embedded Design]]></category>
		<category><![CDATA[PSoC 4000S]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Assembly. Machine Code]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=4992</guid>

					<description><![CDATA[Cypress introduced it&#8217;s first mass market microcontroller in 2001. It used a Cypress designed 8 bit CISC processor running at 24 MHz, with as little as 4 KB Flash and 256 bytes RAM. Wrapped around that was a neat array of programmable analog and digital blocks. This may not sound like much, but with a [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Cypress introduced it&#8217;s first mass market microcontroller in 2001. It used a Cypress designed 8 bit CISC processor running at 24 MHz, with as little as 4 KB Flash and 256 bytes RAM. Wrapped around that was a neat array of programmable analog and digital blocks. This may not sound like much, but with a creative mindset you could get these parts to do amazing things. For instance, I once implemented a complete ultrasonic ranging sensor with full wave analog demodulation in a single PSOC1 as shown below.</p>
<figure id="attachment_4993" aria-describedby="caption-attachment-4993" style="width: 1024px" class="wp-caption aligncenter"><a href="https://iotexpert.com/wp-content/uploads/2018/02/UltrasonicRangingPSOC1.jpg"><img decoding="async" width="1024" height="430" class="size-large wp-image-4993" alt="" src="https://iotexpert.com/wp-content/uploads/2018/02/UltrasonicRangingPSOC1-1024x430.jpg" srcset="https://iotexpert.com/wp-content/uploads/2018/02/UltrasonicRangingPSOC1-1024x430.jpg 1024w, https://iotexpert.com/wp-content/uploads/2018/02/UltrasonicRangingPSOC1-600x252.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/02/UltrasonicRangingPSOC1-300x126.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/02/UltrasonicRangingPSOC1-768x323.jpg 768w, https://iotexpert.com/wp-content/uploads/2018/02/UltrasonicRangingPSOC1.jpg 1040w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption id="caption-attachment-4993" class="wp-caption-text">PSOC1 Ultrasonic Ranging</figcaption></figure>
<p>With CPU resources at a premium, you had to write tight, efficient code to get the most out of PSOC1. A single C library could consume the entire Flash. Consequently, I wrote a <em>lot</em> of assembly code. That&#8217;s not so bad, since I actually enjoy it more than C. There&#8217;s a certain elegance to well written, fully commented machine code. In the case of PSOC1, here&#8217;s what you had to work with: 5 registers, some RAM and Flash. That&#8217;s it. Real Men Write In Assembly.</p>
<figure id="attachment_4995" aria-describedby="caption-attachment-4995" style="width: 518px" class="wp-caption aligncenter"><a href="https://iotexpert.com/wp-content/uploads/2018/02/M8Carch.jpg"><img loading="lazy" decoding="async" width="518" height="341" class="size-full wp-image-4995" alt="" src="https://iotexpert.com/wp-content/uploads/2018/02/M8Carch.jpg" srcset="https://iotexpert.com/wp-content/uploads/2018/02/M8Carch.jpg 518w, https://iotexpert.com/wp-content/uploads/2018/02/M8Carch-300x197.jpg 300w" sizes="auto, (max-width: 518px) 100vw, 518px" /></a><figcaption id="caption-attachment-4995" class="wp-caption-text">M8C Architecture</figcaption></figure>
<p>&nbsp;</p>
<p>We&#8217;ll start with simple machine code instruction to make the CPU do something. You can reference the M8C assembly language user guide <a href="http://www.cypress.com/file/72341/download">here</a> for more details. To get the M8C to execute 2+3=5 we write:</p>
<p><span style="font-family: Courier New;color: black">mov A,2       ;Load A with 2<br />
add A,3       ;Add 3 to A. Result=5 is in A<br />
</span></p>
<p>We can get fancy by using variables. Let&#8217;s add R=P+Q. Assume P is at RAM location 0x20 and Q is at location 0x21, and R is at 0x22</p>
<p><span style="font-family: Courier New;color: black">;Initialize variables<br />
mov [0x20],2  ;Load P with 2<br />
mov [0x21],3  ;Load Q with 3</span></p>
<p><span style="font-family: Courier New;color: black">;Add variables<br />
mov X,[0x20]  ;X &lt;- P<br />
mov A,[0x21]  ;A &lt;- Q<br />
adc [X],A     ;X &lt;- P + Q<br />
mov [0x22],X  ;R &lt;- X<br />
</span><br />
The fun thing about assembly is you can always dream up cool ways of doing things in less operations based on the machine&#8217;s instruction set. For example, we can simplify the above code as follows:</p>
<p><span style="font-family: Courier New;color: black">;Add variables<br />
mov [0x20],[0x22]   ;R &lt;- P<br />
adc [0x22],[0x21]   ;R &lt;- P + Q</span></p>
<p>In my experience, a good programmer with expert knowledge of the instruction set and CPU resources can always write better code than a compiler. There&#8217;s a certain human creativity that algorithms can&#8217;t match.</p>
<p>All that being said, I had not seen a good &#8220;machine code 101&#8221; tutorial for writing assembly in PSOC Creator on modern ARM M0 processors. So let&#8217;s walk through one now. We&#8217;ll use a CY8CKIT-145 and blink the LED. It&#8217;s just what happens to be laying around on the lab bench. Any PSOC4 kit will do.</p>
<p><img loading="lazy" decoding="async" width="518" height="341" class="size-full wp-image-4995 aligncenter" alt="CY8CKIT-145-40XX" src="http://www.cypress.com/sites/default/files/media-embed/263821/CY8CKIT-145_image.png" /></p>
<p>We&#8217;ll start by creating a standard project in PSOC Creator, drop a Digital Output pin on the schematic and call it &#8220;LED&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2018/02/1.jpg"><img loading="lazy" decoding="async" width="1023" height="585" class="alignnone wp-image-5014 size-full" alt="" src="https://iotexpert.com/wp-content/uploads/2018/02/1.jpg" srcset="https://iotexpert.com/wp-content/uploads/2018/02/1.jpg 1023w, https://iotexpert.com/wp-content/uploads/2018/02/1-600x343.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/02/1-300x172.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/02/1-768x439.jpg 768w" sizes="auto, (max-width: 1023px) 100vw, 1023px" /></a></p>
<p>Then open the .CYDWR file and drag pin LED to P2[5], since that&#8217;s where it is on the LED board. Yours may be in a different place on whatever board you are using.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2018/02/2.jpg"><img loading="lazy" decoding="async" width="871" height="579" class="alignnone size-full wp-image-5015" alt="" src="https://iotexpert.com/wp-content/uploads/2018/02/2.jpg" srcset="https://iotexpert.com/wp-content/uploads/2018/02/2.jpg 871w, https://iotexpert.com/wp-content/uploads/2018/02/2-600x399.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/02/2-300x199.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/02/2-768x511.jpg 768w" sizes="auto, (max-width: 871px) 100vw, 871px" /></a></p>
<p>Now under &#8220;Source Files&#8221; in the workspace directory you will delete main.c and replace with main.s</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2018/02/3JPG.jpg"><img loading="lazy" decoding="async" width="343" height="567" class="alignnone size-full wp-image-5016" alt="" src="https://iotexpert.com/wp-content/uploads/2018/02/3JPG.jpg" srcset="https://iotexpert.com/wp-content/uploads/2018/02/3JPG.jpg 343w, https://iotexpert.com/wp-content/uploads/2018/02/3JPG-181x300.jpg 181w" sizes="auto, (max-width: 343px) 100vw, 343px" /></a></p>
<p>Now right clock on &#8220;Source Files&#8221;, select &#8220;Add New File&#8221; and select &#8220;GNU ARM Assembly File&#8221; in the dialog. Rename the file from GNUArmAssembly01.s to main.s</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2018/02/4.jpg"><img loading="lazy" decoding="async" width="524" height="402" class="alignnone size-full wp-image-5017" alt="" src="https://iotexpert.com/wp-content/uploads/2018/02/4.jpg" srcset="https://iotexpert.com/wp-content/uploads/2018/02/4.jpg 524w, https://iotexpert.com/wp-content/uploads/2018/02/4-300x230.jpg 300w" sizes="auto, (max-width: 524px) 100vw, 524px" /></a></p>
<p>Your workspace ends up looking like this:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2018/02/5.jpg"><img loading="lazy" decoding="async" width="319" height="339" class="alignnone size-full wp-image-5018" alt="" src="https://iotexpert.com/wp-content/uploads/2018/02/5.jpg" srcset="https://iotexpert.com/wp-content/uploads/2018/02/5.jpg 319w, https://iotexpert.com/wp-content/uploads/2018/02/5-282x300.jpg 282w" sizes="auto, (max-width: 319px) 100vw, 319px" /></a></p>
<p>So far, so good. Now open main.s, delete everything if it&#8217;s not empty and add the following code. This sets up the IDE for M0 assembly architecture</p>
<p><span style="font-family: Courier New;color: black">// ==============================================<br />
// ARM M0 Assembly Tutorial<br />
//<br />
// 01 &#8211; Blink LED<br />
// ==============================================<br />
.syntax unified<br />
.text<br />
.thumb<br />
</span><br />
Next we need to include register definitions for the chip we are using. These are all from the PSOC4 Technical Reference Manual (TRM)</p>
<p><span style="font-family: Courier New;color: black">// ==============================================<br />
// Includes<br />
// ==============================================<br />
.include &#8220;cydevicegnu_trm.inc&#8221;<br />
</span></p>
<p>Then we are going to do some .equ statements, same as #define in C. This identifies the Port 2 GPIO data register plus bits for the LED pin in on and off state</p>
<p><span style="font-family: Courier New;color: black">// ==============================================<br />
// Defines<br />
// ==============================================<br />
.equ LED_DR,CYREG_GPIO_PRT2_DR          // LED data reg address<br />
.equ LED_PIN,5                          // P2.5<br />
.equ LED_OFF,1&lt;&lt;led_pin                 // 0010 0000<br />
.equ LED_ON,~LED_OFF                    // 1101 1111<br />
</span></p>
<p>Now you add the right syntax to set up main()</p>
<p><span style="font-family: Courier New;color: black">// ==============================================<br />
// main<br />
// ==============================================<br />
.global main<br />
.func main, main<br />
.type main, %function<br />
.thumb_func<br />
</span></p>
<p>Finally we add the code for main, which is pretty simple:</p>
<p><span style="font-family: Courier New;color: black">main:<br />
ldr r5,=LED_DR      // Load GPIO port addr to r5</span></p>
<p><span style="font-family: Courier New;color: black">loop0:<br />
ldr r6,=LED_ON      // Move led data to r6<br />
str r6,[r5]         // Write r6 data to r5 addr</span></p>
<p><span style="font-family: Courier New;color: black">ldr r0,=0xFFFFFF    // Argument passed in r0<br />
bl CyDelayCycles    // Delay for N cycles</span></p>
<p><span style="font-family: Courier New;color: black">ldr r6,=LED_OFF     // Move led data to r6<br />
str r6,[r5]         // Write r6 data to r5 addr</span></p>
<p><span style="font-family: Courier New;color: black">ldr r0,=0xFFFFFF    // Argument passed in r0<br />
bl CyDelayCycles    // Delay for N cycles</span></p>
<p><span style="font-family: Courier New;color: black">b loop0             // Branch loop0</span></p>
<p><span style="font-family: Courier New;color: black">.endfunc            // End of main<br />
.end                // End of code<br />
</span></p>
<p>One thing to note: The function CyDelayCycles is defined CyBootAsmGnu.s. Any function in assembly gets its arguments passed by the first 4 registers r0,r1,r2 and r3. Before calling the function you simply load r0 with the argument then do a bl (branch with link). This is also why I avoided the first 4 registers when messing with LED data. If you&#8217;re interested in doing more with ARM assembly, definitely read the <a href="https://iotexpert.com/wp-content/uploads/2018/02/m0p_trm.pdf">Cortex M0+ Technical Reference Manual</a>. It&#8217;s a great primer for the M0+ instruction set.</p>
<p>That&#8217;s it. End result is a blinking LED. Cool thing is you can use PSOC Creator with all it&#8217;s nice features, but sill access the power of machine code.</p>
<p>You can get the project ZIP file <a href="https://iotexpert.com/wp-content/uploads/2018/02/M0_ASM_v2.zip">here</a>.</p>
<p>Regards<br />
Darrin Vallis</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2018/02/20180209_133339.jpg"><img loading="lazy" decoding="async" width="1024" height="768" class="alignnone size-large wp-image-5022" alt="" src="https://iotexpert.com/wp-content/uploads/2018/02/20180209_133339-1024x768.jpg" srcset="https://iotexpert.com/wp-content/uploads/2018/02/20180209_133339-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2018/02/20180209_133339-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/02/20180209_133339-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/02/20180209_133339-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><a href="https://iotexpert.com/wp-content/uploads/2018/02/M0_ASM_v2.zip"></a><a href="https://iotexpert.com/wp-content/uploads/2018/02/20180209_133339.jpg"></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/lost-art-assembly-language-programming/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>Serial Wire View with PSOC4</title>
		<link>https://iotexpert.com/serial-wire-view-with-psoc4/</link>
					<comments>https://iotexpert.com/serial-wire-view-with-psoc4/#respond</comments>
		
		<dc:creator><![CDATA[Darrin Vallis]]></dc:creator>
		<pubDate>Sat, 18 Nov 2017 01:17:08 +0000</pubDate>
				<category><![CDATA[CY8CKIT-042]]></category>
		<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[Devices]]></category>
		<category><![CDATA[Embedded Design]]></category>
		<category><![CDATA[PSoC 4000S]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[PSoC4 BLE]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=4707</guid>

					<description><![CDATA[I use PSOC4 to invent all kinds of unique solutions for customers. Usually, they want them field upgradeable to deploy new features or fix bugs. Fortunately Cypress has a great I2C boot loader to meet this need, so I use the heck out of it. Cypress has a great debugger built into PSOC Creator which [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I use PSOC4 to invent all kinds of unique solutions for customers. Usually, they want them field upgradeable to deploy new features or fix bugs. Fortunately Cypress has a great <a href="http://www.cypress.com/documentation/application-notes/an86526-psocr-4-and-psoc-analog-coprocessor-i2c-bootloader-zh">I2C boot loader</a> to meet this need, so I use the heck out of it.</p>
<p>Cypress has a great debugger built into <a href="http://www.cypress.com/products/psoc-creator-integrated-design-environment-ide">PSOC Creator</a> which fully supports all the ARM Serial Wire Debug protocols such as breakpoints, single step, memory, register viewing etc. However, when you are running a boot loader <em>the debugger does not work!</em> Why not? Because with a boot loader there are two applications resident in PSOC4: The boot loader and application. This is not supported by Cypress implementation of SWD.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/bootloader.jpg"><img loading="lazy" decoding="async" width="300" height="155" class="alignnone wp-image-4710 size-medium" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/bootloader-300x155.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/bootloader-300x155.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/11/bootloader-600x311.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/11/bootloader.jpg 653w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Where does this leave you, the intrepid code developer, when debugging a boot loader project? Personally, I have used all kinds of methods: debug UART interface, debug I2C interface, bang out states on pins, debug Bluetooth interface &#8230; and on and on. You get the idea. All these methods burn a communications interface and require extra pins on the chip. Sometimes that&#8217;s not possible.</p>
<p>The issue recently came to a head when a customer very nearly in production experienced a boot loader failure. One system out of a few thousand was &#8220;bricked&#8221; when they tried to field  update in the lab. Their pinout is frozen, they can&#8217;t add new hardware so how do we look inside PSOC4 and see what&#8217;s going on?</p>
<p>I woke up at 2 AM and thought &#8220;Ah Ha! SWV!&#8221; (Yes, I Am A Geek) Serial Wire View is an ARM native debug protocol that let&#8217;s you XRAY the insides of any ARM MCU <em>with the right interface</em>. SWV is a protocol which runs on the SWD pins (clock and data) but also needs the Serial Wire Output (SWO) pin. Cypress left the SWO pin and associated IP off of PSOC4 to save die cost, foiling my great idea. Brief interlude to drink and bang head on desk.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/3272886-coresight-debug.png"><img loading="lazy" decoding="async" width="300" height="222" class="aligncenter wp-image-4712 size-medium" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/3272886-coresight-debug-300x222.png" srcset="https://iotexpert.com/wp-content/uploads/2017/11/3272886-coresight-debug-300x222.png 300w, https://iotexpert.com/wp-content/uploads/2017/11/3272886-coresight-debug-600x443.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/3272886-coresight-debug-768x567.png 768w, https://iotexpert.com/wp-content/uploads/2017/11/3272886-coresight-debug-1024x756.png 1024w, https://iotexpert.com/wp-content/uploads/2017/11/3272886-coresight-debug.png 1190w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Fortunately, I don&#8217;t give up easily. At least my subconscious does not. Woke up the next night thinking &#8220;Ah Ha!&#8221; again. Wife was mildly annoyed, but tolerates my idiosyncrasies.</p>
<p>Cypress has a nice software UART transmitter implementation. I shamelessly stole it, modified for my purposes and created a custom component. (It&#8217;s pretty easy to do this by the way) Baud rate was modified to 230 KBps and the output pin forced to a specific pin with a control file.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/dtview2.jpg"><img loading="lazy" decoding="async" width="767" height="301" class="alignnone wp-image-4717 size-full" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/dtview2.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/dtview2.jpg 767w, https://iotexpert.com/wp-content/uploads/2017/11/dtview2-600x235.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/11/dtview2-300x118.jpg 300w" sizes="auto, (max-width: 767px) 100vw, 767px" /></a></p>
<p>Once the component is in place, you can use its _DView_Printf( ) API call to display any debug data. Here is an example:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/code.jpg"><img loading="lazy" decoding="async" width="816" height="227" class="alignnone size-full wp-image-4723" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/code.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/code.jpg 816w, https://iotexpert.com/wp-content/uploads/2017/11/code-600x167.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/11/code-300x83.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/11/code-768x214.jpg 768w" sizes="auto, (max-width: 816px) 100vw, 816px" /></a></p>
<p>More about that output pin. Cypress sells a tool for programming and debugging PSOC called <a href="http://www.cypress.com/documentation/development-kitsboards/cy8ckit-002-psoc-miniprog3-program-and-debug-kit">CY8CKIT-002</a>, aka MiniProg3. The programming connector consists of VDD, GND, reset, SWD clock and SWD data as shown below.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Header.jpg"><img loading="lazy" decoding="async" width="300" height="192" class="alignnone size-medium wp-image-4719" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/Header-300x192.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Header-300x192.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/11/Header-600x384.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/11/Header-768x492.jpg 768w, https://iotexpert.com/wp-content/uploads/2017/11/Header.jpg 814w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Since we can&#8217;t use SWD protocol for debugging anyway, we can change the pins from SWD to normal GPIO. <em>The pins still function for programming</em>. By default they are in SWD mode as shown.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/SWD_Pins.jpg"><img loading="lazy" decoding="async" width="300" height="194" class="alignnone size-medium wp-image-4720" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/SWD_Pins-300x194.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/SWD_Pins-300x194.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/11/SWD_Pins.jpg 587w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Going to the system tab of the .CYDWR file, we can change them to GPIO.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/ChangeToGPIO.jpg"><img loading="lazy" decoding="async" width="634" height="258" class="alignnone wp-image-4721 size-full" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/ChangeToGPIO.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/ChangeToGPIO.jpg 634w, https://iotexpert.com/wp-content/uploads/2017/11/ChangeToGPIO-600x244.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/11/ChangeToGPIO-300x122.jpg 300w" sizes="auto, (max-width: 634px) 100vw, 634px" /></a></p>
<p>Once we do that, the pins look like this. Here&#8217;s the trick. We now assign the TX output of our DTView component to pin 3[2], which is available  on the SWD programming header, pin 5.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/TX-UART.jpg"><img loading="lazy" decoding="async" width="300" height="204" class="alignnone size-medium wp-image-4722" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/TX-UART-300x204.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/TX-UART-300x204.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/11/TX-UART.jpg 533w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Can you see where we are going with this? Printf( ) data is now coming out of PSOC4 on pin 3[2], easily accessible on our debug header. This is where MiniProg3 comes in. It can actually receive data as a 230 KBps RX UART on its XRES pin. Weird, right? By building a simple interface cable we can get the data from your debug header into MiniProg3.</p>
<p>MiniProg3 XRES &#8212;&#8212; SWD HEADER pin 5</p>
<p>MiniProg3   GND &#8212;&#8212; SWD HEADER pin 2</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/20171114_102729.jpg"><img loading="lazy" decoding="async" width="653" height="490" class="alignnone wp-image-4726 size-full" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/20171114_102729.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/20171114_102729.jpg 653w, https://iotexpert.com/wp-content/uploads/2017/11/20171114_102729-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/11/20171114_102729-300x225.jpg 300w" sizes="auto, (max-width: 653px) 100vw, 653px" /></a></p>
<p>However, MiniProg3 does not show up as a COM port on your PC, so how do we the data? It needs to be accessed by a host application running the PP_COM API. This is documented under <em>PSOC Programmer Component Object Model COM Interface Guide</em>, Cypress specification <span style="font-family: Arial;font-size: xx-small"></span>001-45209. If you installed PSOC Creator or Programmer, this document is actually on your PC under C:\Program Files (x86)\Cypress\Programmer\Documents. Engineers don&#8217;t like to read instructions. Amazing what you can find when you do.</p>
<p>I wrote a simple  console application which opens MiniProg3 using PP_COM, retrieves data from the serial RX pin via USB and displays it like a simple terminal program. Voila! You now have a serial debugger that works for any PSOC4 project using MiniProg3 as your USB to serial dongle.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/DTViewOutput.jpg"><img loading="lazy" decoding="async" width="1024" height="388" class="alignnone size-large wp-image-4728" alt="" src="https://iotexpert.com/wp-content/uploads/2017/11/DTViewOutput-1024x388.jpg" srcset="https://iotexpert.com/wp-content/uploads/2017/11/DTViewOutput-1024x388.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/11/DTViewOutput-600x227.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/11/DTViewOutput-300x114.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/11/DTViewOutput-768x291.jpg 768w, https://iotexpert.com/wp-content/uploads/2017/11/DTViewOutput.jpg 1111w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Customer was really happy with this. We were able to immediately see his problem and fixed it in about 5 minutes.</p>
<p>Finally, here are all the source files</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/DTView-Firmware.zip">DTView Firmware</a> : PSOC Creator example project and DTView component</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/DTViewer-Setup.zip">DTViewer Binary</a> : Installer for DTViewer console</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/ViewerSource.zip">ViewerSource</a> : Complete source code for DTViewer console (Requires Visual Studio 2015)</p>
<p>That&#8217;s all. Have fun with the new debugging tool.</p>
<p>DTV</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/serial-wire-view-with-psoc4/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CY3280 MBR3 &#038; WICED CYW943907</title>
		<link>https://iotexpert.com/cy3280-mbr3-wiced-cyw943907/</link>
					<comments>https://iotexpert.com/cy3280-mbr3-wiced-cyw943907/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 14 Sep 2017 11:14:55 +0000</pubDate>
				<category><![CDATA[CY943907]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[WICED]]></category>
		<category><![CDATA[WIFI]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=4134</guid>

					<description><![CDATA[Summary In the last Article I talked about the GE Megahackathon.  One of the groups at the event got interested in using a CY3280 MBR3 to send signals via a WICED CYW943907 to the Particle IO server which was connected to a Particle Photon.  I helped them with the implementation and thought that it would [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the last Article I talked about the <a href="https://iotexpert.com/2017/09/11/cypress-development-kits-ge-mega-hackthon/" target="_blank" rel="noopener">GE Megahackathon</a>.  One of the groups at the event got interested in using a CY3280 MBR3 to send signals via a WICED CYW943907 to the Particle IO server which was connected to a <a href="https://iotexpert.com/category/devkits/particle-photon/" target="_blank" rel="noopener">Particle Photon</a>.  I helped them with the implementation and thought that it would be useful to show here.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4892.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4892-e1505331571825-768x1024.jpg" alt="CYW3280 &amp; WICED CYW943907" width="768" height="1024" class="alignnone wp-image-4139 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4892-e1505331571825-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4892-e1505331571825-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4892-e1505331571825-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4892-e1505331571825-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<h1>Cypress CY3280 MBR3</h1>
<p>The CY3280 MBR development kit is a CapSense demonstration kit that shows the Mechanical Button Replacement 3 chip.  It features 4 CapSense buttons with LEDs, a proximity sensor, and a buzzer.  It is connected to another MCU via the Arduino pins. of the WICED CYW943907.  The device sits on the I2C bus and acts as an I2C Slave.  You configure it using EZ Click.</p>
<p>When you run EZ Click you can setup the configure the internal registers of the MBR3 to make the board act like a bunch of different things.  In this case I turned on</p>
<ul>
<li>The MBR buttons 1-4 (you can see them in the picture above)</li>
<li>The Flanking Sensor rejection which makes it so that you can only press one button at a time.</li>
<li>All of the automatic tuning features.</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.41-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.41-PM.png" alt="EZ-Click CY3280" width="904" height="771" class="alignnone wp-image-4137 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.41-PM.png 904w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.41-PM-600x512.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.41-PM-300x256.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.41-PM-768x655.png 768w" sizes="auto, (max-width: 904px) 100vw, 904px" /></a></p>
<p>Once the main CapSense is configured, I moved to the other part of the configuration where I setup</p>
<ul>
<li>The 4 LEDs to toggle and be full brightness when on</li>
<li>The buzzer to buzz for 100ms at 4kHz when something happens</li>
<li>The host interrupt pin as CS15/SH/HI.  This made the Arduino pin D2 be an interrupt when something happened so that WICED would poll the MBR3</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.55-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.55-PM.png" alt="EZ-Click CY3280" width="905" height="768" class="alignnone wp-image-4136 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.55-PM.png 905w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.55-PM-600x509.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.55-PM-300x255.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-2.16.55-PM-768x652.png 768w" sizes="auto, (max-width: 905px) 100vw, 905px" /></a></p>
<p>Once these settings were all done, I downloaded the firmware configuration via the KitProg USB connector.  Then I tested it using the <a href="https://iotexpert.com/?s=bridge+control+panel" target="_blank" rel="noopener">bridge control panel</a> which I have shown you a bunch of different times in the past.  The MBR3 acts as an I2C slave.  To find out what the state of the buttons are you need to read register 0xAA.  The only little trick is that the chip goes to sleep to save power.  In order to wake it up you need to send an I2C transaction, which ends up getting NAK&#8217;d.  But the next transaction you send will be ACKd.  In the screenshot below you can see that I tried two of the buttons (0x08 and 0x20)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-4.06.59-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-4.06.59-PM.png" alt="Bridge Control Panel" width="850" height="672" class="alignnone wp-image-4144 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-4.06.59-PM.png 850w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-4.06.59-PM-600x474.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-4.06.59-PM-300x237.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-4.06.59-PM-768x607.png 768w" sizes="auto, (max-width: 850px) 100vw, 850px" /></a></p>
<p>One problem that I had is that the power system of this board is setup to take 5V from the Arduino base board but the WICED development kit gives only 3.3v.  Here is a picture of the power system from the MBR3 schematic.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-3.36.57-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-3.36.57-PM-1024x522.png" alt="CY3280 Power Supply" width="1024" height="522" class="alignnone wp-image-4141 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-3.36.57-PM-1024x522.png 1024w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-3.36.57-PM-600x306.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-3.36.57-PM-300x153.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-3.36.57-PM-768x391.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-3.36.57-PM.png 1125w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The MBR3 can run on 3.3Vs.  In fact it can run all the way down to 1.7v and up to 5.5v, but for some reason (which I can&#8217;t remember) we made the board only work with 5.0v.  To fix this problem I removed J12 and then wired a wire from the 3.3V Arduino pin.  The wire is soldered onto the 3.3v pin, but has a female connector on the other side so that it can be plugged into J12.  Here is a picture:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4890.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4890-e1505327051755-1024x768.jpg" alt="CY3280" width="1024" height="768" class="alignnone wp-image-4138 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4890-e1505327051755-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4890-e1505327051755-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4890-e1505327051755-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4890-e1505327051755-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The last thing that I needed to do was move the jumpers to position &#8220;A&#8221; which made the host interrupt pin be connected to D2, and move the I2C jumpers so that the MBR3 was connected to the Arduino instead of the P5LP kitprog.  You can see that in the J3_scl and J3_sda in the picture above.</p>
<h1>WICED CYW943907</h1>
<p>The <a href="http://www.cypress.com/documentation/development-kitsboards/cyw943907aeval1f-evaluation-kit" target="_blank" rel="noopener">CYW934907AEVAL1F</a> is an development kit for the Cypress 43907 MCU+WiFi module.  The WICED CYW943907 board can do dual band (2.4 and 5Ghz), 802.11 a/b/g/n,  Ethernet and a whole bunch of other stuff.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4893.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4893-e1505333784420-1024x768.jpg" alt="WICED CYW943907" width="1024" height="768" class="alignnone wp-image-4145 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4893-e1505333784420-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4893-e1505333784420-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4893-e1505333784420-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4893-e1505333784420-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The first firmware that I wrote in WICED Studio:</p>
<ul>
<li>Sets up an ISR to unlock a semaphore when the interrupt occurs</li>
<li>Initialized WICED_GPIO_9 to be an input and connected to an ISR &#8230; this is also known as Arduino D2</li>
<li>Setup the I2C Master Hardware in the 43907</li>
<li>Wait for a semaphore (from the ISR)</li>
<li>Read the I2C register 0xAA from the MBR</li>
</ul>
<p>The only trick in the firmware is that I read the I2C with a &#8220;do&#8221; loop until I get a valid result, meaning that the MBR3 has woken up.</p>
<pre class="lang:c decode:true">#include "wiced.h"

#define I2C_ADDRESS (0x37)
#define BUTTON_REG (0xAA)

wiced_semaphore_t buttonPress;

/* Interrupt service routine for the button */
void button_isr(void* arg)
{
    wiced_rtos_set_semaphore(&amp;buttonPress);
}

/* Main application */
void application_start( )
{
    wiced_init();	/* Initialize the WICED device */
    WPRINT_APP_INFO(("Started\n"));

    wiced_result_t result;
    wiced_rtos_init_semaphore(&amp;buttonPress);

    // WICED_GPIO_9 is the MBR3 Interrupt Pin
    wiced_gpio_init(WICED_GPIO_9,INPUT_PULL_UP);
    wiced_gpio_input_irq_enable(WICED_GPIO_9, IRQ_TRIGGER_FALLING_EDGE, button_isr, NULL); /* Setup interrupt */

    /* Setup I2C master */
    const wiced_i2c_device_t i2cDevice = {
            .port = WICED_I2C_2,
            .address = I2C_ADDRESS,
            .address_width = I2C_ADDRESS_WIDTH_7BIT,
            .speed_mode = I2C_STANDARD_SPEED_MODE
    };

    wiced_i2c_init(&amp;i2cDevice);

    /* Tx buffer is used to set the offset */
    uint8_t tx_buffer[] = {BUTTON_REG};
    uint8_t buttonStatus;

    while ( 1 )
    {

        wiced_rtos_get_semaphore(&amp;buttonPress,WICED_WAIT_FOREVER);

        // Do this until the MBR3 is alive.  It goes into deep sleep and wakes when you
        // send the first command.
        do {
            result = wiced_i2c_write(&amp;i2cDevice, WICED_I2C_START_FLAG | WICED_I2C_STOP_FLAG, tx_buffer, sizeof(tx_buffer));
        }
        while(result != WICED_SUCCESS);

        result=wiced_i2c_read(&amp;i2cDevice, WICED_I2C_START_FLAG | WICED_I2C_STOP_FLAG, &amp;buttonStatus, sizeof(buttonStatus));
        WPRINT_APP_INFO(("Button State = %X\n", buttonStatus)); /* Print data to terminal */
    }
}
</pre>
<p>Once that is programmed I program and test the firmware.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-1.46.36-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-1.46.36-PM.png" alt="Testing WICED CYW943907" width="877" height="522" class="alignnone wp-image-4135 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-1.46.36-PM.png 877w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-1.46.36-PM-600x357.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-1.46.36-PM-300x179.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-13-at-1.46.36-PM-768x457.png 768w" sizes="auto, (max-width: 877px) 100vw, 877px" /></a></p>
<p>In the next article I will modify all of this firmware and make the WICED CYW943907 send data via HTTP to the Cloud.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy3280-mbr3-wiced-cyw943907/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>FreeRTOS PSoC Template Project</title>
		<link>https://iotexpert.com/freertos-psoc-template-project/</link>
					<comments>https://iotexpert.com/freertos-psoc-template-project/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 31 Aug 2017 12:24:28 +0000</pubDate>
				<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[FreeRTOS]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=4097</guid>

					<description><![CDATA[Summary In the last article I showed you clever FreeRTOS PSoC Component&#8230; and the talked about some of the issues that I had with it.  In this article I will talk about a self-contained FreeRTOS PSoC Template project that includes everything for FreeRTOS and Tracealyzer all in one project.  My idea was that when I [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the last <a href="https://iotexpert.com/2017/08/29/freertos-psoc-component/">article</a> I showed you clever FreeRTOS PSoC Component&#8230; and the talked about some of the issues that I had with it.  In this article I will talk about a self-contained FreeRTOS PSoC Template project that includes everything for FreeRTOS and Tracealyzer all in one project.  My idea was that when I start a new project I will just make a copy of the template project, rename it, then move on.</p>
<p>My FreeRTOS PSoC Template has</p>
<ul>
<li>FreeRTOS with the files in in the same directory (i.e. not referenced externally)</li>
<li>Tracealyzer with the files in the same directory &amp; all of the streamports including RTT and the UART DMA</li>
<li>All of the files organized into PSoC Creator folders</li>
<li>A template main.c</li>
<li>All of the build settings configured</li>
</ul>
<p>This project is checked into <a href="https://github.com/iotexpert/PSoC-FreeRTOS-Template" target="_blank" rel="noopener">GitHub</a> and you can find it git@<span>github.com:iotexpert/PSoC-FreeRTOS-Template.git</span></p>
<h1>Building the FreeRTOS PSoC Template</h1>
<p>I started the process by creating a blank PSoC project called &#8220;FreeRTOS_Template&#8221;.  I then went into the Windows Explorer and copied the entire FreeRTOS source directory into the FreeRTOS PSoC Template Project directory.  Then I copied the Percepio TraceRecorder library into the FreeRTOS PSoC Template project.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM.png" alt="FreeRTOS PSoC Template Directory Structure" width="660" height="613" class="alignnone wp-image-4099 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM.png 660w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM-600x557.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM-300x279.png 300w" sizes="auto, (max-width: 660px) 100vw, 660px" /></a></p>
<p>By having both of the source directories in my project it isolated this project from changes in the FreeRTOS or the TraceRecorder.  Obviously that is a double edged sword.  The next thing that I did was use the Windows Explorer to copy FreeRTOSConfig.h, trcConfig.h, trcSnapshotConfig.h and trcStreamingConfig.h into the project.   Once all of the files were in my project directory is was time to fix up the PSoC Creator Project.</p>
<p>To do this I created a folder called &#8220;FreeRTOS_Source&#8221; in the &#8220;Header Files&#8221; and &#8220;Source Files&#8221; folders in my template project.  You can do this by right clicking and selecting &#8220;Add-&gt;New Folder&#8221;.  Then I added all of the appropriate .h and .c files from FreeRTOS source directory.  This gives me the following project view:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.29.53-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.29.53-AM.png" alt="FreeRTOS PSoC Template PSoC Creator Header Files" width="243" height="296" class="alignnone wp-image-4101 size-full" /></a></p>
<p>And Source Files (notice that I also added heap_4.c which I generally use for memory management)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.30.04-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.30.04-AM.png" alt="FreeRTOS PSoC Template PSoC Creator Source Files" width="238" height="219" class="alignnone wp-image-4100 size-full" /></a></p>
<p>Then I add the configuration files FreeRTOSConfig.h, trcConfig.h, trcSnapshotConfig.h, trcStreamingConfig.h and trcStreamingport.h.  Next I do the same thing for the TraceRecorder library which makes my project look like this:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.33.16-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.33.16-AM.png" alt="" width="328" height="526" class="alignnone size-full wp-image-4102" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.33.16-AM.png 328w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.33.16-AM-187x300.png 187w" sizes="auto, (max-width: 328px) 100vw, 328px" /></a></p>
<p>Then I modify the build settings to add the include directories:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM.png" alt="FreeRTOS PSoC Template Build Settings" width="754" height="493" class="alignnone wp-image-4104 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM.png 754w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM-600x392.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM-300x196.png 300w" sizes="auto, (max-width: 754px) 100vw, 754px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.49-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.49-AM.png" alt="FreeRTOS PSoC Template PSoC Creator Include Path" width="352" height="311" class="alignnone wp-image-4103 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.49-AM.png 352w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.49-AM-300x265.png 300w" sizes="auto, (max-width: 352px) 100vw, 352px" /></a></p>
<p>Now you can modify the FreeRTOSConfig.h to include all of the Tracealyzer stuff:</p>
<pre class="start-line:89 lang:c decode:true ">/* A header file that defines trace macro can be included here. */
#if ( configUSE_TRACE_FACILITY == 1 )
#include "trcRecorder.h"
#endif

#endif /* FREERTOS_CONFIG_H */</pre>
<p>Then I setup a new tab in the schematic to contain the DMA UART Streamport.  You can read all about the UART DMA Streamport in this <a href="https://iotexpert.com/2017/08/08/percepio-tracealyzer-a-psoc-dma-streamport/" target="_blank" rel="noopener">article</a>.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM.png" alt="FreeRTOS PSoC Template PSoC Creator Streamport Schematic" width="983" height="1004" class="alignnone wp-image-4105 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM.png 983w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM-600x613.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM-294x300.png 294w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM-768x784.png 768w" sizes="auto, (max-width: 983px) 100vw, 983px" /></a></p>
<p>By putting that part of the stream port on a separate schematic page I can now do a right click and disable the page when I am not using the Tracealyzer streamport.  Disabling a page of the schematic completely removes everything from the build.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.40.39-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.40.39-AM.png" alt="PSoC Creator Schematic Disable Settings" width="329" height="160" class="alignnone wp-image-4106 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.40.39-AM.png 329w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.40.39-AM-300x146.png 300w" sizes="auto, (max-width: 329px) 100vw, 329px" /></a></p>
<p>Next I create files called FreeRTOS_Start.h/.c to put in the startup code:</p>
<pre class="lang:c decode:true ">#include &lt;project.h&gt;
#include "FreeRTOS.h"

extern void xPortPendSVHandler(void);
extern void xPortSysTickHandler(void);
extern void vPortSVCHandler(void);

#define CORTEX_INTERRUPT_BASE          (16)
void FreeRTOS_Start()
{
    /* Handler for Cortex Supervisor Call (SVC, formerly SWI) - address 11 */
    CyIntSetSysVector( CORTEX_INTERRUPT_BASE + SVCall_IRQn,
        (cyisraddress)vPortSVCHandler );
    
    /* Handler for Cortex PendSV Call - address 14 */
	CyIntSetSysVector( CORTEX_INTERRUPT_BASE + PendSV_IRQn,
        (cyisraddress)xPortPendSVHandler );    
    
    /* Handler for Cortex SYSTICK - address 15 */
	CyIntSetSysVector( CORTEX_INTERRUPT_BASE + SysTick_IRQn,
        (cyisraddress)xPortSysTickHandler );
}
</pre>
<p>Finally I make a template main.c that starts everything and has a simple ledTask and instructions for changing Memory Management scheme and the TraceRecorder.</p>
<pre class="lang:c decode:true ">// This template has heap_4.c included in the project.  If you want a 
// different heap scheme then remove heap_4 from the project and add 
// the other scheme from FreeRTOS/Source/portable/memmag

// TraceRecorder
// There are methods
// 1. Snapshot mode
// 2. Streaming UART/DMA
// 3. Streaming JLINK RTT
//
// To use method 1: 
// - in FreeRTOSConfig.h make this line be 1 (currently line 45)
//#define configUSE_TRACE_FACILITY                1
// - in trcConfig.h configure the TRC_CFG_RECORDER 
// #define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
//
// To use method 2:
// - in FreeRTOSConfig.h make this line be 1 (currently line 45)
//#define configUSE_TRACE_FACILITY                1
// - in trcConfig.h configure the TRC_CFG_RECORDER
//#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING
//
// This project currently has the PSoC UART Streaming Port
// add the TraceRecorder/streamports/PSoC_Serial/trcStreamingPort.c to the project
// add the TraceRecorder/streamports/PSoC_Serial/include/trcStreamingPort.h
// add the TraceRecorder/streamports/PSoC_Serial/include to the compiler include directories
// Enable the Trace_DMA schematic sheet and make sure UART pins are assigned correctly
// This port depends on the UART being named UART and the DMA being named "DMA"
//
// To use method 3: JLINK RTT
// Remove the previous streamport files from the project
// Remove the Streamport include path
// add the TraceRecorder/streamports/JLink_RTT/Segger_RTT.c to the project
// add the TraceRecorder/streamports/JLink_RTT/Segger_RTT_Printf.c to the project
// add the TraceRecorder/streamports/JLink_RTT/include/trcStreamingPort.h
// add the TraceRecorder/streamports/JLink_RTT/include/Segger_RTT.h
// add the TraceRecorder/streamports/JLink_RTT/include/Segger_RTT_Conf.h
// add the TraceRecorder/streamports/JLink_RTT/include to the compiler include directories


#include "project.h"
#include "FreeRTOS.h"
#include "timers.h"

// An example Task
void ledTask(void *arg)
{
    (void)arg;
    while(1)
    {
        RED_Write(~RED_Read());
        vTaskDelay(500);  
    }
}

int main(void)
{
    CyGlobalIntEnable;
    FreeRTOS_Start();
    
    #if ( configUSE_TRACE_FACILITY == 1 )
    vTraceEnable(TRC_START);
    #endif
    
    xTaskCreate(ledTask,"LED Task",configMINIMAL_STACK_SIZE,0,1,0);
    vTaskStartScheduler();  // Will never return
    while(1);               // Eliminate compiler warning
}
</pre>
<p>&nbsp;</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Topic</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/02/23/psoc4-freertos-port/" target="_blank" rel="noopener noreferrer">FreeRTOS: A PSoC4 FreeRTOS Port</a></td>
<td >An introduction to making FreeRTOS work on PSoC 4</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/23/freertos-psoc-examples/" target="_blank" rel="noopener noreferrer">FreeRTOS PSoC Examples</a></td>
<td >Using multiple tasks in FreeRTOS</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/25/psoc-freertos-queue-example/" target="_blank" rel="noopener noreferrer">FreeRTOS Queue Example</a></td>
<td >Using a queue to communicate between tasks</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/30/psoc-6-freertos-first-example/" target="_blank" rel="noopener noreferrer">PSoC 6 FreeRTOS - The First Example</a></td>
<td >Booting FreeRTOS on PSoC 6</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/01/psoc-freertos-binary-semaphore/" target="_blank" rel="noopener noreferrer">FreeRTOS Binary Semaphore</a></td>
<td >An first example of a binary semaphore</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/08/psoc-freertos-binary-semaphore-part-2/">FreeRTOS Binary Semaphore (Part 2)</td>
<td >Removing polling in the UART Task</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/20/psoc-freertos-counting-semaphore/" target="_blank" rel="noopener">FreeRTOS Counting Semaphore</a></td>
<td >An example using a counting semaphore</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/22/psoc-freertos-sharing-the-i2c-bus/" target="_blank" rel="noopener">PSoC FreeRTOS</a></td>
<td >Reading I2C Sensors with a shared I2C Bus</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/22/psoc-freertos-task-notify/" target="_blank" rel="noopener">PSoC FreeRTOS Task Notify</a></td>
<td >A light weight scheme to replace Semaphores</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/24/psoc-freertos-task-notification-value/" target="_blank" rel="noopener">PSoC FreeRTOS Task Notification Values</a></td>
<td >A very light weight method to transfer one word of information into a task</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/freertos-psoc-template-project/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>PSoC Creator Projects</title>
		<link>https://iotexpert.com/psoc-creator-projects/</link>
					<comments>https://iotexpert.com/psoc-creator-projects/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 18 Jul 2017 10:00:39 +0000</pubDate>
				<category><![CDATA[PSoC Creator]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3844</guid>

					<description><![CDATA[Summary When building a PSoC Creator project there are a number of &#8220;sources&#8221; of &#8220;source code&#8221; including: Cypress PSoC Component Code from the Cypress Component Library (which end up in the Generated_Source directory) Your C Source code files .h/.c e.g main.c Your Components from your Component Library (which end up in the Generated Source Source [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>When building a PSoC Creator project there are a number of &#8220;sources&#8221; of &#8220;source code&#8221; including:</p>
<ul>
<li>Cypress PSoC Component Code from the Cypress Component Library (which end up in the Generated_Source directory)</li>
<li>Your C Source code files .h/.c e.g main.c</li>
<li>Your Components from your Component Library (which end up in the Generated Source Source directory)</li>
<li>Other Libraries of code (e.g. FreeRTOS or Percepio Tracelyzer)</li>
</ul>
<p>There are (at least) five tools which need to &#8220;know&#8221; about where the source code for your project resides including:</p>
<ul>
<li>Workspace Explorer (so you can browse the files and open the code in an editor)</li>
<li>PSoC Creator Code Editor (so Intellisense works correctly)</li>
<li>GCC Compiler</li>
<li>Linker</li>
<li>Debugger</li>
</ul>
<p>Here is a video where I talk about the files structure of PSoC Creator Projects:</p>
<div class="jupiterx-oembed"><iframe loading="lazy" title="PSoC Creator 101: B. PSoC Creator File Structure" width="500" height="281" src="https://www.youtube.com/embed/AhIjzFzVO1w?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>PSoC Creator takes care of so many of these details automatically for you, so I have not put much thought into how these things work.  But, in the last few months, I have been building projects that use FreeRTOS, which has made me contemplate how things go together.  This is the genesis of this Article.</p>
<p>Lets start with a blank project (which I created for the CY8CKIT-044).  When you make this project you can see that you get:</p>
<ul>
<li>A Workspace (called Workspace07) that contains one project.  The name is just a default name + a number that Creator made for you.</li>
<li>A Project (called Design01)</li>
<li>A Schematic (called TopDesign.cysch)</li>
<li>Design Wide Resources (called Design01.cydwr)</li>
<li>A folder for Header Files which contains a file called cyapicallbacks.h</li>
<li>A folder for Source Files that contains main.c</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.43.09-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.43.09-PM-1024x598.png" alt="PSoC Creator Blank Project" width="1024" height="598" class="alignnone wp-image-3849 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.43.09-PM-1024x598.png 1024w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.43.09-PM-600x351.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.43.09-PM-300x175.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.43.09-PM-768x449.png 768w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.43.09-PM.png 1350w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>When you look at the disk you will see a directory at the top level called &#8220;Workspace07&#8221;.  This directory contains:</p>
<ul>
<li>The workspace file called Workspace07.cywrk and a user specific settings file called Workspace07.cywrk.arh (the .arh is my windows login).  This binary file contains references to all of the projects that are part of the Workspace.  Plus other Workspace configuration.</li>
<li>A directory called &#8220;Design01.cydsn&#8221;.  This directory contains everything required for the project.</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.31-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.31-PM.png" alt="PSoC Creator files in Windows Explorer" width="893" height="452" class="alignnone wp-image-3852 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.31-PM.png 893w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.31-PM-600x304.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.31-PM-300x152.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.31-PM-768x389.png 768w" sizes="auto, (max-width: 893px) 100vw, 893px" /></a></p>
<p>When I look in the directory called &#8220;Design01.cydsn&#8221; I see</p>
<ul>
<li>Design01.cyprj (an xml file that contains all of the information about the project)</li>
<li>Design01.cydwr (an xml file that contains all of the Design Wide Resource settings)</li>
<li>The two source files main.c and cyapicallbacks.h</li>
<li>A directory called &#8220;TopDesign&#8221;</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.53-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.53-PM.png" alt="PSoC Creator - Project Directory" width="892" height="449" class="alignnone wp-image-3851 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.53-PM.png 892w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.53-PM-600x302.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.53-PM-300x151.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.55.53-PM-768x387.png 768w" sizes="auto, (max-width: 892px) 100vw, 892px" /></a></p>
<p>In the TopDesign directory you will find the TopDesign.cysch which is the binary file of the schematic.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.56.08-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.56.08-PM.png" alt="PSoC Creator - Top Design Directory" width="893" height="455" class="alignnone wp-image-3850 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.56.08-PM.png 893w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.56.08-PM-600x306.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.56.08-PM-300x153.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-4.56.08-PM-768x391.png 768w" sizes="auto, (max-width: 893px) 100vw, 893px" /></a></p>
<p>Now that we have accounted for all of the &#8220;basic&#8221; project stuff.  I will run &#8220;Generate Application&#8221; from the build menu.</p>
<h1>Cypress PSoC Creator Components</h1>
<p>After the Application Generation is done you will see a bunch of more stuff in the Workspace Explorer.  Specifically a new folder called &#8220;Generated_Source&#8221;.  In that folder you will see a folder called &#8220;PSoC4&#8221; that contains a bunch of files plus some more folders.  These folders are created by the application generation process to hold the source code for components including cy_boot, cy_dmac, and cy_lfclk.  But you say, &#8220;I didn&#8217;t place any components&#8221;, and that is true,  but PSoC Creator did this automatically for you when you made the project.  These source files are used to get the PSoC booted, the linker setup, the CMSIS core definitions etc.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.22-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.22-PM.png" alt="PSoC Creator Workspace Explorer" width="287" height="692" class="alignnone wp-image-3855 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.22-PM.png 287w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.22-PM-124x300.png 124w" sizes="auto, (max-width: 287px) 100vw, 287px" /></a></p>
<p>When you look on the disk, you will see a completely different hierarchy than you see in the Workspace Explorer.  In fact you will see all of these files in a directory called &#8220;Generated_Source/PSoC4&#8221;.  This tells us something important.  The workspace explorer gives you hierarchy so that you can see the different files grouped together logically.  BUT this hierarchy is completely unrelated to how the build process works (more on this in a minute) or how the files reside on the disk.  DANGER DANGER WILL ROGERS!!!  (these Folders are actually called &#8220;Filter Folders&#8221; and you can read about them in the PSoC Help Topic &#8220;Creating Folders&#8221;)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.43-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.43-PM.png" alt="PSoC Creator - Workspace Explorer Generated_Source" width="810" height="800" class="alignnone wp-image-3854 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.43-PM.png 810w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.43-PM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.43-PM-600x593.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.43-PM-300x296.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.06.43-PM-768x759.png 768w" sizes="auto, (max-width: 810px) 100vw, 810px" /></a></p>
<p>When you place a component in the schematic (e.g. a UART) and run the build again you will find more folders &amp; files in the Generated_Source section of the Workspace Explorer</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.15.40-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.15.40-PM.png" alt="PSoC Creator - Workspace Explorer" width="238" height="161" class="alignnone wp-image-3857 size-full" /></a></p>
<p>But when you look in Generated_Source directory on the disk, you will find ALL of those files in one directory.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.16.28-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.16.28-PM.png" alt="PSoC Creator - Generated_Source Directory" width="810" height="623" class="alignnone wp-image-3856 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.16.28-PM.png 810w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.16.28-PM-600x461.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.16.28-PM-300x231.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.16.28-PM-768x591.png 768w" sizes="auto, (max-width: 810px) 100vw, 810px" /></a> <a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.15.40-PM.png"></a></p>
<p>When you place a component, PSoC Creator takes the API from the Component Library, processes it, names it correctly, adds it to your &#8220;.cyprj&#8221; file so that the Workspace Explorer can see it, then copies the code into your Generated_Source directory.  You could edit it there, but if you do, you are at risk to having it overwritten the next time you build the project.  All of the configuration you do to a component gets turned into c-source that resides in the Generated_Source directory</p>
<p>When you delete a component, the related generated source code (e.g., UART_1.*) won’t be visible in Workspace Explorer, but IT STILL LIVES ON DISK. This is a consequence of our legacy “merge region” support.  The user may have edited the file and PSoC Creator doesn’t want to destroy those edits.  This can cause inconsistencies between what Workspace Explorer shows the user and what the compiler actually sees:</p>
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">
<ul>
<li>PSoC Creator will NOT compile any irrelevant .c files present in the file system.</li>
<li>However, the compiler WILL see any stale .h files that happen to be lying around when it processes #includes.</li>
</ul>
<p>So, what is a merge region?  When PSoC Creator was originally created, it was recognized that there was occasionally need for a user to put code into a generated file e.g. an interrupt handler.  And we also wanted PSoC Creator to be able to regenerate that file.  If you look around in Generated_Source files, you will find sections of code that look like lines 27-30.  If you put code between those funny looking comments, it will not be blown away when you regenerate your application.  In other words PSoC Creator preserves all of the code in merge regions.  This mode has mostly be supplanted by the use of the &#8220;cyapicallbacks.h&#8221; functionality.</p>
</div>
</div>
</div>
</div>
</div>
<pre class="lang:c decode:true ">/*******************************************************************************
* Function Name: isr_1_Interrupt
********************************************************************************
*
* Summary:
*   The default Interrupt Service Routine for isr_1.
*
*   Add custom code between the START and END comments to keep the next version
*   of this file from over-writing your code.
*
*   Note You may use either the default ISR by using this API, or you may define
*   your own separate ISR through ISR_StartEx().
*
* Parameters:  
*   None
*
* Return:
*   None
*
*******************************************************************************/
CY_ISR(isr_1_Interrupt)
{
    #ifdef isr_1_INTERRUPT_INTERRUPT_CALLBACK
        isr_1_Interrupt_InterruptCallback();
    #endif /* isr_1_INTERRUPT_INTERRUPT_CALLBACK */ 

    /*  Place your Interrupt code here. */
    /* `#START isr_1_Interrupt` */

    /* `#END` */
}
</pre>
<h1>Your Code in C Source Files (.h/.c)</h1>
<p>All of the files in &#8220;Header Files&#8221; and &#8220;Source Files&#8221; are considered to be owned by you.  In other words, PSoC Creator will never make changes to those files.  PSoC Creator starts by giving you copies of two template files, main.c and cyapicallbacks.h.  These files are yours to edit and you are responsible for the contents.</p>
<p>If you are making a project that is to big to logically fit into just main.c you may want to split it up into multiple .c and .h file.  You can do this by adding .c and .h source files to your project.  Right click the &#8220;Header Files&#8221; folder (or &#8220;Source Files&#8221;) and select &#8220;New Item&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.27.20-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.27.20-PM.png" alt="PSoC Creator - Add Existing Item" width="399" height="275" class="alignnone wp-image-3861 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.27.20-PM.png 399w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.27.20-PM-300x207.png 300w" sizes="auto, (max-width: 399px) 100vw, 399px" /></a></p>
<p>Then enter the name of the file and select the FileType (in this case I did &#8220;blahblah.h&#8221;)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.28.44-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.28.44-PM.png" alt="PSoC Creator - Add New Item" width="582" height="463" class="alignnone wp-image-3863 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.28.44-PM.png 582w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.28.44-PM-300x239.png 300w" sizes="auto, (max-width: 582px) 100vw, 582px" /></a></p>
<p>After doing that I will have a new file in the Workspace Explorer</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.31.09-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.31.09-PM.png" alt="PSoC Creator - Workspace Explorer Header Files" width="187" height="98" class="alignnone wp-image-3864 size-full" /></a></p>
<p>Plus I will have the same file in the Design01.cydsn directory</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.29.20-PM.png"></a><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.29.20-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.29.20-PM.png" alt="PSoC Creator - Windows Explorer Top Project Directory" width="810" height="585" class="alignnone wp-image-3862 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.29.20-PM.png 810w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.29.20-PM-600x433.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.29.20-PM-300x217.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-5.29.20-PM-768x555.png 768w" sizes="auto, (max-width: 810px) 100vw, 810px" /></a></p>
<p>All of the files that I add by doing &#8220;New Item&#8221; will end up in the &#8220;right&#8221; folder and reside in the project directory on the disk.</p>
<h1>Your Components</h1>
<p>In PSoC Creator, it is possible to create your own Components.  You can read or watch videos about this process</p>
<ul>
<li><a href="http://www.cypress.com/training/psoc-video-tutorial-series-how-create-custom-components" target="_blank" rel="noopener"></a><a href="https://iotexpert.com/?s=create+component" target="_blank" rel="noopener">IoT Expert Component Examples</a><a href="http://www.cypress.com/training/psoc-video-tutorial-series-how-create-custom-components" target="_blank" rel="noopener"> </a></li>
<li><a href="http://www.cypress.com/training/psoc-video-tutorial-series-how-create-custom-components" target="_blank" rel="noopener">Video Tutorial</a></li>
<li>PSoC Creator Help &#8211;&gt; Documentation &#8211;&gt; <a href="http://www.cypress.com/documentation/component-datasheets/psoc-creator-component-author-guide" target="_blank" rel="noopener">Component Author Guide</a></li>
</ul>
<p>After you have a library with Custom Components, you can add it as a dependency to your project by right clicking on the project and selecting &#8220;Dependencies &#8230;&#8221;  Then navigating to the .cyprj file with your components.  In this case I added the <a href="https://github.com/iotexpert/IoTExpert_PSoC_Components" target="_blank" rel="noopener">IoTExpert_PSoC_Components</a> library</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.12.36-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.12.36-AM-637x1024.png" alt="PSoC Creator - Add Existing" width="637" height="1024" class="alignnone wp-image-3871 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.12.36-AM-637x1024.png 637w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.12.36-AM-600x964.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.12.36-AM-187x300.png 187w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.12.36-AM.png 686w" sizes="auto, (max-width: 637px) 100vw, 637px" /></a></p>
<p>You can see that the &#8220;IoTExpert_Components&#8221; shows up in the User Dependencies</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.10.32-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.10.32-AM.png" alt="PSoC Creator - Project Dependencies" width="920" height="960" class="alignnone wp-image-3870 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.10.32-AM.png 920w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.10.32-AM-600x626.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.10.32-AM-288x300.png 288w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.10.32-AM-768x801.png 768w" sizes="auto, (max-width: 920px) 100vw, 920px" /></a></p>
<p>Once this is done you will see the new Component Libraries in the Component Catalog.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.15.45-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.15.45-AM.png" alt="PSoC Creator - Custom Component Catalog" width="736" height="482" class="alignnone wp-image-3872 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.15.45-AM.png 736w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.15.45-AM-600x393.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-9.15.45-AM-300x196.png 300w" sizes="auto, (max-width: 736px) 100vw, 736px" /></a></p>
<p>Components from your custom libraries act exactly the same as the Cypress Components.  Specifically, after you place a custom component in your schematic, when you build the project, it will process the source code, copy it into the &#8220;Generated_Source&#8221; directory, add the files to your WorkSpace Explorer etc.</p>
<p>A custom component is a good way to easily add a library of source code to your project.</p>
<h1>3rd Party Libraries</h1>
<p>The last class of source code comes from 3rd Party Libraries.  Classically, these libraries have one more more directories with .c, .h and .a (static libraries) files.  There are some of the files which you might want to modify to configure your version of the library, there are other files that you just need to be compiled into your project.  This situation leaves you with some choices.</p>
<ul>
<li>You can copy all of the library files into your project directory (then add existing item)</li>
<li>You can copy some of the library files into your project directory and leave some of the files in the library directory</li>
<li>You can add references to the library files into your project</li>
</ul>
<p>The main issue that you need to consider is Source Code Control &#8211; Version Management of your project.  If you copy the library files into your project directories, then you are sure that they won&#8217;t change out from underneath you.  BUT, if the library has a bug fix, then you won&#8217;t automatically get it.  It is often considered a best practice to have a &#8220;single source of truth&#8221;.  When you copy files into your project, you violate that principal.  This is a choice that you will need to grapple with.</p>
<p>This is probably best explained with a real example, FreeRTOS.  I have been using the hybrid model.  Specifically I copy the configuration files into my project, but leave the rest of FreeRTOS in my downloaded directory and use references in my PSoC Creator Project.  The process is:</p>
<ul>
<li>In the Windows Explorer copy FreeRTOSConfig.h into my project directory</li>
<li>Right click the project and &#8220;Add Existing Item&#8221;</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.34-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.34-AM.png" alt="PSoC Creator - Add FreeRTOS" width="506" height="188" class="alignnone wp-image-3877 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.34-AM.png 506w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.34-AM-300x111.png 300w" sizes="auto, (max-width: 506px) 100vw, 506px" /></a></p>
<p>Then select &#8220;FreeRTOSConfig.h&#8221; from my project directory</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.49-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.49-AM.png" alt="PSoC Creator - Add FreeRTOS" width="687" height="653" class="alignnone wp-image-3876 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.49-AM.png 687w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.49-AM-600x570.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.43.49-AM-300x285.png 300w" sizes="auto, (max-width: 687px) 100vw, 687px" /></a></p>
<p>After that you can see that &#8220;FreeRTOSConfig.h&#8221; is part of my project in the &#8220;Header Files&#8221; section</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.45.12-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.45.12-AM.png" alt="PSoC Creator - Project Explorer" width="309" height="374" class="alignnone wp-image-3878 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.45.12-AM.png 309w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.45.12-AM-248x300.png 248w" sizes="auto, (max-width: 309px) 100vw, 309px" /></a></p>
<p>I like the rest of the FreeRTOS Files to be part of the project but not actually copied into my project directory.  To do this, I add the required C-Files using the same technique of &#8220;Add Existing&#8221;  To make FreeRTOS work you need to add all of the C-Files and H-Files in:</p>
<ul>
<li><span>FreeRTOS/Source/portable/GCC/ARM_CM0 </span></li>
<li><span>FreeRTOS/Source/include</span></li>
<li><span>FreeRTOS/Source/</span></li>
<li><span>FreeRTOS/Source/portable/MemMang/heap_1.c</span></li>
</ul>
<p>PSoC Creator will automatically take care of telling the compiler where to get the C-Files.  However, it will not take care of the H-Files.  In order to do this you need to change the build settings to add the path to all of the H-Files that you use.  Modify the build settings by right-clicking the project and selecting &#8220;Build Settings &#8230;&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.55.39-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.55.39-AM.png" alt="PSoC Creator - Add FreeRTOS" width="307" height="564" class="alignnone wp-image-3880 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.55.39-AM.png 307w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.55.39-AM-163x300.png 163w" sizes="auto, (max-width: 307px) 100vw, 307px" /></a></p>
<p>Then selecting the &#8220;&#8230;&#8221; on Design01 &#8211;&gt; Arm GCC &#8230; &#8211;&gt; Compiler &#8211;&gt; Additional Include Directories</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.56.36-AM.png">\</a><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.56.36-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.56.36-AM.png" alt="PSoC Creator - Add FreeRTOS Include Directories" width="637" height="488" class="alignnone wp-image-3881 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.56.36-AM.png 637w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.56.36-AM-600x460.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.56.36-AM-300x230.png 300w" sizes="auto, (max-width: 637px) 100vw, 637px" /></a></p>
<p>Then press the &#8220;New&#8221; and then the &#8220;&#8230;&#8221; to browse to the directory you want to add.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.59.12-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.59.12-AM.png" alt="PSoC Creator - Include Directories" width="662" height="973" class="alignnone wp-image-3882 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.59.12-AM.png 662w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.59.12-AM-600x882.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-10.59.12-AM-204x300.png 204w" sizes="auto, (max-width: 662px) 100vw, 662px" /></a></p>
<p>Finally you will end up with a window that looks like this:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.00.20-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.00.20-AM.png" alt="PSoC Creator - FreeRTOS Include Path" width="364" height="314" class="alignnone wp-image-3883 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.00.20-AM.png 364w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.00.20-AM-300x259.png 300w" sizes="auto, (max-width: 364px) 100vw, 364px" /></a></p>
<p>And when you look at the build options you will see the &#8220;-I..\..\..\FreeRTOSv9.0.0\FreeRTOS\Source\include&#8221; is added to the compiler options (look at the little window at the bottom)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.01.02-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.01.02-AM.png" alt="PSoC Creator - Build Settings" width="693" height="524" class="alignnone wp-image-3884 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.01.02-AM.png 693w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.01.02-AM-600x454.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-16-at-11.01.02-AM-300x227.png 300w" sizes="auto, (max-width: 693px) 100vw, 693px" /></a></p>
<p>Thank you to Nick from the PSoC Creator Team for reviewing my Article.  He is one of the lead technical genius&#8217; that made PSoC Creator the bad-ass software that it is.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/psoc-creator-projects/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Embedded World 2017: PSoC Analog CoProcessor CapSense GUI</title>
		<link>https://iotexpert.com/embedded-world-2017-psoc-analog-coprocessor-capsense-gui/</link>
					<comments>https://iotexpert.com/embedded-world-2017-psoc-analog-coprocessor-capsense-gui/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 09 Mar 2017 22:18:22 +0000</pubDate>
				<category><![CDATA[Embedded World 2017]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[WIFI]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3156</guid>

					<description><![CDATA[Summary I have been building up pieces of code that are going to allow me to show the PSoC Analog CoProcessor &#8211;&#62; WICED WiFi &#8211;&#62; Amazon IoT &#8211;&#62; WICED WiFi &#8211;&#62; Secret New Chip &#8211;&#62; Robot Arm.   In the previous two articles (part1, part2) I have shown you how to build most of the WICED firmware. [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2>Summary</h2>
<p>I have been building up pieces of code that are going to allow me to show the <a href="http://www.cypress.com/products/psoc-analog-coprocessor" target="_blank">PSoC Analog CoProcessor</a> &#8211;&gt; <a href="http://www.cypress.com/products/ieee-80211-abgn-wlan-sdio-usb-and-mimo" target="_blank">WICED WiFi</a> &#8211;&gt; <a href="https://aws.amazon.com/iot/" target="_blank">Amazon IoT</a> &#8211;&gt; <a href="http://www.cypress.com/products/ieee-80211-abgn-wlan-sdio-usb-and-mimo" target="_blank">WICED WiFi</a> &#8211;&gt; Secret New Chip &#8211;&gt; Robot Arm.   In the previous two articles (<a href="https://iotexpert.com/2017/03/08/embedded-world-2017-wiced-wifi-mqtt-and-the-amazon-iot-cloud/">part1</a>, <a href="https://iotexpert.com/2017/03/09/embedded-world-2017-wiced-wifi-mqtt-and-the-amazon-iot-cloud-part-2/">part2</a>) I have shown you how to build most of the WICED firmware.  In this article I am going to focus on the PSoC Analog CoProcessor firmware (but if you look real close you can see the secret new chip&#8217;s development kit).</p>
<p>In the picture below you can see the red shield board.  This is a shield with the PSoC Analog CoProcessor plus a bunch of sensors that show the power of that chip.  The shield also includes 4x CapSense Buttons which I am going to use to set the position of the Robot Arm.  The PSoC will serve as a front end companion to the WICED WiFi Development Kit.  They will communicate via I2C with the PSoC acting as an I2C Slave and the WICED WiFi as a master.  Here is a picture of the all of parts minus Amazon.com&#8217;s cloud.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/IMG_3844.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/IMG_3844.jpg" alt="Embedded World 2017 Components" width="4032" height="3024" class="alignnone wp-image-3162 size-full" /></a></p>
<h2>PSoC Analog CoProcessor</h2>
<p>The PSoC Analog CoProcessor has the new Cypress CapSense block that gives you a bunch of new features, including enough measurement range to measure a capacitative humidity sensor (which you can see in the upper left hand part of the board).  For this demonstration I am just going to use the 4 CapSense buttons.  They will serve as the user interface for the Robot Arm.  The 4 buttons will set 4 different positions, 20%,40%,60%,80%.  I will be talking in much more detail about this shield in coming posts (later next month)</p>
<h2>PSoC Analog CoProcessor Schematic</h2>
<p>The PSoC Creator schematic is pretty straight forward.  I use the EZI2C slave to provide communication for the WICED board.  There are 4x LEDs that sit right next to the CapSense buttons,  and there are the 4x CapSense buttons.  The only slightly odd duck is the Bootloadable component which I use because when I designed the shield I did not put a programmer on it.  The BootLoadable allows me to me to load new firmware into the PSoC via the I2C interface.  Here is the PSoC Creator Schematic:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.36-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.36-PM.png" alt="PSoC Creator Schematic" width="1024" height="730" class="alignnone wp-image-3169 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.36-PM.png 1024w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.36-PM-600x428.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.36-PM-300x214.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.36-PM-768x548.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The CapSense configuration just specifies the use of 4x CapSense buttons that are automatically tuned by the Cypress magic.</p>
<p><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.58-PM.png" alt="CapSense Configuration" width="1570" height="784" class="alignnone wp-image-3168 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.58-PM.png 1570w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.58-PM-600x300.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.58-PM-300x150.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.58-PM-768x384.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.12.58-PM-1024x511.png 1024w" sizes="auto, (max-width: 1570px) 100vw, 1570px" /></p>
<p>The last step in configuring the schematic is to assign all of the pins to the correct locations.</p>
<p><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.13.36-PM.png" alt="Pin Assignment" width="1492" height="560" class="alignnone wp-image-3167 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.13.36-PM.png 1492w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.13.36-PM-600x225.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.13.36-PM-300x113.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.13.36-PM-768x288.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.13.36-PM-1024x384.png 1024w" sizes="auto, (max-width: 1492px) 100vw, 1492px" /></p>
<h2>PSoC Analog CoProcessor Firmware</h2>
<p>One of the great things about all of this process is how easy the firmware is to write.</p>
<ul>
<li>Line 3 declares a buffer that will be used to relay the position information to the WICED board.  I start the position at 50%</li>
<li>Lines 8-9 start the EZI2C which starts up the EZI2C protocol and tells it to read from the &#8220;position&#8221; variable</li>
<li>Lines 10-11 gets the CapSense going</li>
</ul>
<p>Inside of the infinite while(1) loop, I read from the CapSense and do the right thing</p>
<ul>
<li>Lines 17-22 reads the CapSense status</li>
<li>Lines 24-27 set the correct position based on which buttons are pressed (notice that if no button is pressed then the position stays the same)</li>
<li>Line 29 turns on the Bootloader if B0 &amp; B3 are pressed</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.59.13-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.59.13-PM.png" alt="PSoC Analog CoProcessor Main.c" width="1546" height="1160" class="alignnone wp-image-3174 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.59.13-PM.png 1546w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.59.13-PM-600x450.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.59.13-PM-300x225.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.59.13-PM-768x576.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-4.59.13-PM-1024x768.png 1024w" sizes="auto, (max-width: 1546px) 100vw, 1546px" /></a></p>
<h2>Testing the PSoC Analog CoProcessor System</h2>
<p>The easiest way to test the system is to use the Bridge Control Panel which comes as part of the PSoC Creator installation.  It lets me read the value from the EZ2IC buffer to make sure that the CapSense buttons are doing the right thing.  The command language is pretty simple.  You can see in the editor window that I typed &#8220;W42 0 R 42 X p;&#8221;  Everytime I press &#8220;enter&#8221; it sends the I2C commands:</p>
<ul>
<li>Send an I2C start</li>
<li>write the 7-bit I2C address 0x42</li>
<li>write a 0</li>
<li>send a restart</li>
<li>read from address 0x42</li>
<li>read one byte</li>
<li>send a stop</li>
</ul>
<p>You can see that I pressed each button and indeed got 20,40,60,80 (assuming you can convert hex to decimal&#8230; but trust me)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-5.01.29-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-5.01.29-PM.png" alt="Bridge Control Panel" width="1866" height="1354" class="alignnone wp-image-3175 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-5.01.29-PM.png 1866w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-5.01.29-PM-600x435.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-5.01.29-PM-300x218.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-5.01.29-PM-768x557.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-09-at-5.01.29-PM-1024x743.png 1024w" sizes="auto, (max-width: 1866px) 100vw, 1866px" /></a></p>
<p>In the next article I will modify the WICED Publisher to poll the PSoC Analog CoProcessor and then publish the current state.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/embedded-world-2017-psoc-analog-coprocessor-capsense-gui/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ThingSoC: Four I2C OLED Displays with PSoC4L</title>
		<link>https://iotexpert.com/thingsoc-psoc4l-i2c-oled-displays/</link>
					<comments>https://iotexpert.com/thingsoc-psoc4l-i2c-oled-displays/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 06 Feb 2017 11:00:13 +0000</pubDate>
				<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[ThingSoC]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=2830</guid>

					<description><![CDATA[Pattern Agents are running a crowd funding effort for ThingSoC TSoC4L &#8230; help them here Summary In the previous ThingSoC post I took you through building the firmware to make the PSoC4L drive the ThingSoC I2C hub.  Now what?  When originally looking around I saw a picture with 4x LCDs connected to the I2C hub, which I [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4><span style="color: #ff0000;"><span style="color: #008000;">Pattern Agents are running a crowd funding effort for ThingSoC TSoC4L &#8230; help them</span> <a href="https://www.crowdsupply.com/patternagents-llc/thingsoc-grovey?utm_source=thingSOC+Supporters&amp;utm_campaign=f1c4185485-launch_thingsoc_2017_01_23&amp;utm_medium=email&amp;utm_term=0_4aec98a7fc-f1c4185485-112421013" target="_blank" style="color: #ff0000;">here</a></span></h4>
<h2>Summary</h2>
<p>In the <a href="https://iotexpert.com/2017/02/02/thingsoc-tsoc-grovey-i2chub-i2c-hubswitch/" target="_blank">previous</a> ThingSoC post I took you through building the firmware to make the <a href="http://www.cypress.com/documentation/datasheets/psoc-4-psoc-4200l-family-datasheet">PSoC4L</a> drive the ThingSoC I2C hub.  Now what?  When originally looking around I saw a picture with 4x LCDs connected to the I2C hub, which I thought was cool. In this post Ill show you how to do the same thing with PSoC and the <a href="https://github.com/olikraus/u8g2" target="_blank">U8G2</a> library which I talked about in this <a href="https://iotexpert.com/2017/02/01/pinball-driving-oled-using-u8g2-library/" target="_blank">article</a>. To do this I will:</p>
<ol>
<li>Create New PSoC4L Project + Integrate the U8G2 Library</li>
<li>Update the PSoC4L Firmware</li>
<li>Test the PSoC4L Firmware</li>
</ol>
<p>Here is the picture:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/02/lcd_rgb_13.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/02/lcd_rgb_13.jpg" alt="4 I2C Displays, Inspiration" width="640" height="640" class="alignnone wp-image-2839 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/02/lcd_rgb_13.jpg 640w, https://iotexpert.com/wp-content/uploads/2017/02/lcd_rgb_13-300x300.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/02/lcd_rgb_13-100x100.jpg 100w, https://iotexpert.com/wp-content/uploads/2017/02/lcd_rgb_13-600x600.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/02/lcd_rgb_13-150x150.jpg 150w" sizes="auto, (max-width: 640px) 100vw, 640px" /></a></p>
<h2>Create New PSOC4L Project + Integrate the U8G2 Library</h2>
<p>Maybe it should have been obvious, but for some reason it never occurred to me to do a copy/paste to duplicate a project.  I guess that I&#8217;m slow that way.  To do this right click on a project in the workspace explorer and then do paste.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.04.36-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.04.36-AM.png" alt="PSoC Creator Edit Build Settings" width="820" height="1150" class="alignnone wp-image-2851 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.04.36-AM.png 820w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.04.36-AM-600x841.png 600w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.04.36-AM-214x300.png 214w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.04.36-AM-768x1077.png 768w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.04.36-AM-730x1024.png 730w" sizes="auto, (max-width: 820px) 100vw, 820px" /></a></p>
<p>The next step is to integrate the firmware from the U8G2 Library. Start by &#8220;gitting&#8221; with &#8220;git@github.com:olikraus/u8g2.git&#8221;.  Then you need to add the directory to your project by right clicking the project and selecting &#8220;Build Settings&#8221;.  You need to add U8G2 Library to the additional include directories.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.09.47-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.09.47-AM.png" alt="Add the U8G2 Library" width="1588" height="1126" class="alignnone wp-image-2852 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.09.47-AM.png 1588w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.09.47-AM-600x425.png 600w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.09.47-AM-300x213.png 300w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.09.47-AM-768x545.png 768w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.09.47-AM-1024x726.png 1024w" sizes="auto, (max-width: 1588px) 100vw, 1588px" /></a></p>
<p>Add the all of the .h and .c files by right clicking the project and selection &#8220;Add-&gt;Existing Item&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.12.17-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.12.17-AM.png" alt="copy the u8g2 files into the PSoC4L project" width="972" height="1048" class="alignnone wp-image-2853 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.12.17-AM.png 972w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.12.17-AM-600x647.png 600w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.12.17-AM-278x300.png 278w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.12.17-AM-768x828.png 768w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-03-at-8.12.17-AM-950x1024.png 950w" sizes="auto, (max-width: 972px) 100vw, 972px" /></a></p>
<p>Navigate to the U8G2 library and add all of the .c and .h files.  The last thing you need is to bring in the HAL that I wrote for PSoC and described in this <a href="https://iotexpert.com/2017/02/01/pinball-driving-oled-using-u8g2-library/" target="_blank">post</a>.  Specifically you need to bring in the two functions</p>
<ul>
<li>psoc_gpio_and_delay_cb</li>
<li>u8x8_byte_hw_i2c</li>
</ul>
<p>I suppose that I should package the whole thing up in a component.  But, Ill leave that as an exercise for the reader.</p>
<h2>Update the PSoC4L Firmware</h2>
<p>The cool thing about the whole setup with the I2CHUB is that it allows you to have 4 devices with the same I2C address attached to one PSoC SCB at the same time.  To get going with the firmware, I start by defining an array of u8x8_t structures to represent the 4 different displays attaches to the 4 different ports on the I2C hub. (line 186).  Then I create a function called setupDisplay that initializes the display etc. (lines 199-203).  The only trick in the firmware is that <a href="https://en.wikipedia.org/wiki/Dennis_Ritchie" target="_blank">Dennis Ritchie</a> defined arrays to run from 0-3 but the I2C busses are labeled 1-4,  this is the reason for subtracting 1 from the input lcd number.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.19.50-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.19.50-AM.png" alt="PSoC4L Firmware to initialize the U8G2 Display" width="1044" height="404" class="alignnone wp-image-2831 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.19.50-AM.png 1044w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.19.50-AM-600x232.png 600w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.19.50-AM-300x116.png 300w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.19.50-AM-768x297.png 768w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.19.50-AM-1024x396.png 1024w" sizes="auto, (max-width: 1044px) 100vw, 1044px" /></a></p>
<p>The next step is modifying command processors in the main loop.  Specifically, I will add the commands q,w,e,r to startup the displays on I2C ports 1,2,3,4.  And, I will add those commands to the help print out.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.18.57-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.18.57-AM.png" alt="Modifying the PSoC4L CLI" width="652" height="545" class="alignnone wp-image-2832 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.18.57-AM.png 652w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.18.57-AM-600x502.png 600w, https://iotexpert.com/wp-content/uploads/2017/02/Screen-Shot-2017-02-02-at-7.18.57-AM-300x251.png 300w" sizes="auto, (max-width: 652px) 100vw, 652px" /></a></p>
<h2>Test the PSoC4L Firmware</h2>
<p>In order to make a connection from the Grove 4-pin connectors to my breadboard I used <a href="http://www.switchdoc.com" target="_blank">Switch Doc Labs</a> connectors which I bought from <a href="https://www.amazon.com/Cables-Grove-Jumper-Grove-Conversion/dp/B01F25VYF2/ref=sr_1_3?ie=UTF8&amp;qid=1486038649&amp;sr=8-3&amp;keywords=grove+4+pin" target="_blank">Amazon.com</a>.  For some reason you can&#8217;t purchase them from the Switch Doc Labs website or the SeeedStudio website, but they are very handy.  As an unrelated side note I had never seen (or in fact ever heard of) Switch Doc Labs.  But their website has a bunch of tutorials about the Raspberry Pi and Grove ecosystem boards for use with IoT-ifying house plants.  Seemed pretty cool.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/02/41Z4kxiN9DL.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/02/41Z4kxiN9DL.jpg" alt="Grove to Breadboard Switch Doc Labs Breakout Cable" width="500" height="375" class="alignnone wp-image-2833 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/02/41Z4kxiN9DL.jpg 500w, https://iotexpert.com/wp-content/uploads/2017/02/41Z4kxiN9DL-300x225.jpg 300w" sizes="auto, (max-width: 500px) 100vw, 500px" /></a></p>
<p>Now when I press &#8220;qwer&#8221; in my command console I get this:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/02/IMG_3652.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/02/IMG_3652.jpg" alt="PSoC4L Driving 4 OLED LCDs" width="4032" height="3024" class="alignnone size-full wp-image-2860" /></a></p>
<p><span><p>You can find all of the projects in the TSoC Series at my GitHub ThingSoC repository git@github.com:iotexpert/ThingSoC.git</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Index</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/01/25/thingsoc-psoc4l/">ThingSoc: TSoC PSoC4L Development Kit from PatternAgents</a></td>
<td >Introduction to ThingSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/01/30/thingsoc4l-using-debugging-the-psoc4-clock/" target="_blank">ThingSoC PSoC4L: Using &amp; Debugging the PSoC4 Clock</a></td>
<td >Debugging a beta firmware problem</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/02/02/thingsoc-tsoc-grovey-i2chub-i2c-hubswitch/" target="_blank">ThingSoC: The TSoC GROVEY I2CHUB : I2C Hub/Switch</td>
<td >Evaluating the ThingSoC I2C Hub</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/02/06/thingsoc-psoc4l-i2c-oled-displays/" target="_blank">ThingSoC: Multiple I2C Displays</td>
<td >Using the I2CHUB and U8X8 Library</a></td>
<td >A project using ThingSoC I2C Hub &amp; 4 OLED Displays</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/thingsoc-psoc4l-i2c-oled-displays/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Electronica 2016 &#8211; CY8CKIT-145 User Interface</title>
		<link>https://iotexpert.com/electronica-2016-cy8ckit-145-user-interface/</link>
					<comments>https://iotexpert.com/electronica-2016-cy8ckit-145-user-interface/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 07 Nov 2016 10:07:08 +0000</pubDate>
				<category><![CDATA[Cy8CKIT-145]]></category>
		<category><![CDATA[Electronica 2016]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=2225</guid>

					<description><![CDATA[I finally made it to Munich late yesterday afternoon&#8230; then I proceeded to turn my hotel room into an electronics lab as I frantically worked to finish everything for tomorrow.  Earlier this year I wrote a whole series of posts about the PSoC4000S &#38; CY8CKIT-145 after the Embedded World show.  We finally have volume production [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I finally made it to Munich late yesterday afternoon&#8230; then I proceeded to turn my hotel room into an electronics lab as I frantically worked to finish everything for tomorrow.  Earlier this year I wrote a whole series of posts about the <a href="https://iotexpert.com/2016/02/29/psoc4000s-and-the-cy8ckit145-stamp-board-part-1/" target="_blank">PSoC4000S &amp; CY8CKIT-145</a> after the Embedded World show.  We finally have volume production on the development kit and will be giving them out at the show this week.  So, I decided to use the -145 as part of the user interface for my Electronica project.  The devkit functions as the block labeled &#8220;PSoC Capsense&#8221;.  The wire between the &#8220;PSoC Capsense&#8221; and the &#8220;WICED WiFi&#8221; will be I2C (the green and red wire from the picture below)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/electronica-wiced.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/electronica-wiced.png" alt="electronica-wiced" width="1197" height="868" class="alignnone wp-image-2177 size-full" srcset="https://iotexpert.com/wp-content/uploads/2016/11/electronica-wiced.png 1197w, https://iotexpert.com/wp-content/uploads/2016/11/electronica-wiced-600x435.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/electronica-wiced-300x218.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/electronica-wiced-768x557.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/electronica-wiced-1024x743.png 1024w" sizes="auto, (max-width: 1197px) 100vw, 1197px" /></a></p>
<p>The -145 devkit has the PSoC4000S silicon on it which has the new mutual capacitance capsense block.  On the devkit, there are three mutual cap buttons and one slider.  Here is a picture of the devkit connected to the WICED WiFi board that I am going to use:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3318.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3318.jpg" alt="img_3318" width="4032" height="3024" class="alignnone wp-image-2226 size-full" /></a></p>
<p>I want to make as simple of a PSoC Creator project as I can possibly do as I want to be able to easily do it live.  Here it is:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.12.23-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.12.23-AM.png" alt="screen-shot-2016-11-07-at-10-12-23-am" width="888" height="720" class="alignnone wp-image-2228 size-full" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.12.23-AM.png 888w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.12.23-AM-600x486.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.12.23-AM-300x243.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.12.23-AM-768x623.png 768w" sizes="auto, (max-width: 888px) 100vw, 888px" /></a></p>
<p>The CapSense block is configured with three mutual cap buttons and 1 self-cap slider:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.13.54-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.13.54-AM.png" alt="screen-shot-2016-11-07-at-10-13-54-am" width="1726" height="1142" class="alignnone size-full wp-image-2229" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.13.54-AM.png 1726w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.13.54-AM-600x397.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.13.54-AM-300x198.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.13.54-AM-768x508.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.13.54-AM-1024x678.png 1024w" sizes="auto, (max-width: 1726px) 100vw, 1726px" /></a></p>
<p>On this development board, the three mutual cap buttons share the same transmit line, so you need to configure the component that way. The screen shot below shows the configuration of the &#8220;Button1_Tx&#8221; which is set to share the &#8220;Button0_Tx&#8221;.  You need to make the same setting for &#8220;Button2_Tx&#8221;.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.15.34-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.15.34-AM.png" alt="screen-shot-2016-11-07-at-10-15-34-am" width="1728" height="1144" class="alignnone size-full wp-image-2230" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.15.34-AM.png 1728w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.15.34-AM-600x397.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.15.34-AM-300x199.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.15.34-AM-768x508.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.15.34-AM-1024x678.png 1024w" sizes="auto, (max-width: 1728px) 100vw, 1728px" /></a></p>
<p>The next step is to assign all of the pins to the proper locations:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.18.10-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.18.10-AM.png" alt="screen-shot-2016-11-07-at-10-18-10-am" width="1294" height="880" class="alignnone size-full wp-image-2232" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.18.10-AM.png 1294w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.18.10-AM-600x408.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.18.10-AM-300x204.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.18.10-AM-768x522.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.18.10-AM-1024x696.png 1024w" sizes="auto, (max-width: 1294px) 100vw, 1294px" /></a></p>
<p>Finally the smallest amount of firmware that I could think up to hold it all together.</p>
<p>Line 3-6: define a structure that the WICED board will be able to read.  It will represent the position of two of the Servo motors.  The CY_PACKED provides the compiler appropriate key words to make the bytes be right next to each other in the RAM, i.e. not word aligned..</p>
<p>Line 8: initializes both positions to 50%.</p>
<p>Lines 12-17 get the components going</p>
<p>Line 22: Checks to make sure that the CapSense block is not scanning before it reads the results</p>
<p>Line 24: Tells the CapSense block to process the results from the previous scan</p>
<p>Lines 25-31: Looks at the three buttons, sets the LEDs and sets pos1 to be either 25%, 50% or 75%</p>
<p>Line 33: Reads the position of the slider and assigns it to &#8220;pos0&#8221;</p>
<p>Lines 34-35: Gets the scanning going again</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.21.02-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.21.02-AM.png" alt="screen-shot-2016-11-07-at-10-21-02-am" width="1548" height="1254" class="alignnone size-full wp-image-2233" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.21.02-AM.png 1548w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.21.02-AM-600x486.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.21.02-AM-300x243.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.21.02-AM-768x622.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.21.02-AM-1024x830.png 1024w" sizes="auto, (max-width: 1548px) 100vw, 1548px" /></a></p>
<p>To test the system I first used the bridge control panel.  First, connect to the kitprog2.  Then I setup a read from the I2C address (0x08) which is the address of my board.  I then click repeat which runs the read command over and over again.  In the picture below you can see that I tested the three position of the button (25,50 and 75 which are also known as 0x19, 0x32 and 0x4B).  Then I tested the slider by touching it about in the middle (0x3A)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.31.52-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.31.52-AM.png" alt="screen-shot-2016-11-07-at-10-31-52-am" width="1722" height="1358" class="alignnone size-full wp-image-2235" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.31.52-AM.png 1722w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.31.52-AM-600x473.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.31.52-AM-300x237.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.31.52-AM-768x606.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.31.52-AM-1024x808.png 1024w" sizes="auto, (max-width: 1722px) 100vw, 1722px" /></a></p>
<p>The next thing to do was make sure that the WICED devkit could read my I2C slave, so I wrote some WICED firmware to read the I2C registers every 500ms:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.55.08-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.55.08-AM.png" alt="screen-shot-2016-11-07-at-10-55-08-am" width="1578" height="1176" class="alignnone size-full wp-image-2237" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.55.08-AM.png 1578w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.55.08-AM-600x447.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.55.08-AM-300x224.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.55.08-AM-768x572.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.55.08-AM-1024x763.png 1024w" sizes="auto, (max-width: 1578px) 100vw, 1578px" /></a></p>
<p>But, occasionally I  was getting a &#8220;read failed&#8221;:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM.png" alt="screen-shot-2016-11-07-at-10-58-48-am" width="1490" height="1476" class="alignnone size-full wp-image-2238" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM.png 1490w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM-600x594.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM-150x150.png 150w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM-300x297.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM-768x761.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.58.48-AM-1024x1014.png 1024w" sizes="auto, (max-width: 1490px) 100vw, 1490px" /></a></p>
<p>Last night in my sleep deprived state I was struggling like crazy to figure it out.  This morning after some sleep I realized that the WICED board that I have must not like getting its I2C clock stretched.  So, I changed the priority of the I2C interrupt on the PSoC and that fixed the problem:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.28.03-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.28.03-AM.png" alt="screen-shot-2016-11-07-at-10-28-03-am" width="716" height="198" class="alignnone size-full wp-image-2234" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.28.03-AM.png 716w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.28.03-AM-600x166.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-07-at-10.28.03-AM-300x83.png 300w" sizes="auto, (max-width: 716px) 100vw, 716px" /></a></p>
<p>Keep watching here for more updates on the project.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/electronica-2016-cy8ckit-145-user-interface/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Electronica 2016 &#8211; Servo Motor PWMs</title>
		<link>https://iotexpert.com/electronica-2016-servo-motor-pwms/</link>
					<comments>https://iotexpert.com/electronica-2016-servo-motor-pwms/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sun, 06 Nov 2016 00:12:09 +0000</pubDate>
				<category><![CDATA[Electronica 2016]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[WICED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=2208</guid>

					<description><![CDATA[As I talked about in my previous post I am going to use a PSoC as a servo motor controller as well as a CapSense UI.  The problem is that I wanted a really easy way to plug the servo motors into the PSoC.  It seems like all of the servos have a 3 wire [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>As I talked about in my previous post I am going to use a PSoC as a servo motor controller as well as a CapSense UI.  The problem is that I wanted a really easy way to plug the servo motors into the PSoC.  It seems like all of the servos have a 3 wire interface, Power, Ground and PWM.  Here is a picture that I got from <a href="https://www.adafruit.com/products/155" target="_blank">Adafruit&#8217;s</a> website.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/155-01.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/155-01.jpg" alt="155-01" width="970" height="728" class="alignnone wp-image-2214 size-full" srcset="https://iotexpert.com/wp-content/uploads/2016/11/155-01.jpg 970w, https://iotexpert.com/wp-content/uploads/2016/11/155-01-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/11/155-01-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2016/11/155-01-768x576.jpg 768w" sizes="auto, (max-width: 970px) 100vw, 970px" /></a></p>
<p>I was originally hoping that I could connect that servo directly to the PSoC, drive a &#8216;1&#8217; to the power and a &#8216;0&#8217; to the ground and PWM to the third input.  But, it turns out that these things suck some serious juice (100+ma?) so driving the power with the PSoC isn&#8217;t in the cards.  Given them amount of time that I had left, there was not time for a custom board, so I was in the situation of using a breadboard with wires all over the place which is ugly and a bit of a pain.  However, on Thursday I thought that I might find a &#8220;Servo Shield&#8221; and sure enough there are a number of them out there including <a href="https://www.adafruit.com/products/1438" target="_blank">this one</a> which I got from Adafruit.  The problem is this shield uses a 16 channel I2C &#8211;&gt; PWM driver from NXP.  I am not a fan of doing things with peripheral chips that PSoC can do for itself.  But, when I got the shield this morning in the mail there was a cool prototyping area on the shield.  So, I made my own header for connecting to the PSoC.  Here is the front:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3309.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3309-1024x768.jpg" alt="img_3309" width="1024" height="768" class="alignnone wp-image-2211 size-large" srcset="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3309-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_3309-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_3309-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>And here is the back:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3308.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3308.jpg" alt="img_3308" width="4032" height="3024" class="alignnone wp-image-2212 size-full" /></a></p>
<p>You can see that I shorted the whole row of ground together with a big blog of solder and wire.  I did the same thing with the power (the middle row).  Then I made a wire from each of the 4 PWMs pins to a good place on the PSoC (which I could drive the pins directly from one of the TCPWMs)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3300.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3300-e1478389721516.jpg" alt="img_3300" width="3024" height="4032" class="alignnone wp-image-2216 size-full" /></a></p>
<p>The board worked great on my bench.  The only thing that I have done which is VERY questionable is that I wired the power supply for the system directly to the V5.0 aka VBUS&#8230; which I suppose will get me through the conference, but is probably a bad idea (the green wire in the top picture)</p>
<p>As I was flying to Detroit I thought that I might try to see how the I2C-&gt;PWM worked&#8230; so I read the data sheet for the <a href="https://cdn-shop.adafruit.com/datasheets/TB6612FNG_datasheet_en_20121101.pdf" target="_blank">NXP PCA9685</a>.  It turns out that the chip is pretty cool.  You can set the output frequency by setting a divider value in one of the registers (oxFE).  The number you set is val=round(25e6/(4096*rate)) &#8211; 1.  That means for me to get 50hz to drive the motors I need to set the divider to 121.  Then to set the duty cycle each output has a 12-bit PWM where you can set &#8220;LED ON&#8221; and a &#8220;LED Off&#8221; count.  For instance to get a 25% duty cycle you can set the On to 0 and the off to 1024.</p>
<p>After I got off the airplane in Detroit I went to get some &#8220;dinner&#8221; and I wanted to try out the shield so I hooked it up:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3304.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3304.jpg" alt="img_3304" width="4032" height="3024" class="alignnone wp-image-2213 size-full" /></a></p>
<p>You always get a bunch of funny looks in the airport when your table looks like this:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3310.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_3310-e1478390418377.jpg" alt="img_3310" width="3024" height="4032" class="alignnone wp-image-2217 size-full" /></a>This left me with only one problem.  How to drive the shield PWMs onto something that I could see&#8230; I didnt pack my Tek in my carry on (though I suppose I could have used one of those little scopes).  But, I digress.  What I decided to do is make the PSoC echo an input onto on output pin that was connected to an LED.  So, I drew this schematic.  This can only be done in with a PSoC because I used a logic gate in the UDB to flip the 9685 PWM from Low to High so that my active low LED would work right.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-8.02.36-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-8.02.36-PM.png" alt="screen-shot-2016-11-05-at-8-02-36-pm" width="1048" height="452" class="alignnone wp-image-2219 size-full" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-8.02.36-PM.png 1048w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-8.02.36-PM-600x259.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-8.02.36-PM-300x129.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-8.02.36-PM-768x331.png 768w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-8.02.36-PM-1024x442.png 1024w" sizes="auto, (max-width: 1048px) 100vw, 1048px" /></a></p>
<p>Next I fly to Charles De Gaul, the suckiest airport in the first world.  What will I do on the airplane there?  I don&#8217;t, but given those empty beer glasses I may sleep.  More to follow when I get to Germany.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/electronica-2016-servo-motor-pwms/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Electronica + WICED + The Robot Arm</title>
		<link>https://iotexpert.com/electronica-wiced-the-robot-arm/</link>
					<comments>https://iotexpert.com/electronica-wiced-the-robot-arm/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sat, 05 Nov 2016 11:32:51 +0000</pubDate>
				<category><![CDATA[Electronica 2016]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[WICED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=2185</guid>

					<description><![CDATA[The good news is that the Robot Arm arrived from Amazon, which I was very happy about because it was a day late.  The even better news is that it works like a charm.  First I needed to assemble it, which I did with a little bit of help from my able lab technician and [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The good news is that the <a href="https://www.amazon.com/SainSmart-Control-Palletizing-Arduino-MEGA2560/dp/B00NB1DFF2/ref=sr_1_13?ie=UTF8&amp;qid=1478302256&amp;sr=8-13&amp;keywords=robot+arm" target="_blank">Robot Arm</a> arrived from Amazon, which I was very happy about because it was a day late.  The even better news is that it works like a charm.  First I needed to assemble it, which I did with a little bit of help from my able lab technician and a trip to Lowe&#8217;s to get a base.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0003.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0003-e1478302411254-768x1024.jpg" alt="img_0003" width="768" height="1024" class="alignnone wp-image-2188 size-large" srcset="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0003-e1478302411254-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0003-e1478302411254-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0003-e1478302411254-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0003-e1478302411254-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>Then &#8220;we&#8221; attached the base to the Robot.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0008-e1478302627920.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0008-e1478302627920-768x1024.jpg" alt="img_0008" width="768" height="1024" class="alignnone size-large wp-image-2191" srcset="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0008-e1478302627920-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0008-e1478302627920-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0008-e1478302627920-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0008-e1478302627920-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>After the robot arm was put together on the base, I needed a little bit of firmware to run it.  First the schematic:  You can see that I have</p>
<ol>
<li>Two PWMs &#8211; one for each Servo motor</li>
<li>A Capsense slider to move one of the axis on the robot</li>
<li>A switch and LED to turn On/Off the PWMs<a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.51.10-PM.png"></a></li>
</ol>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.04.50-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.04.50-AM.png" alt="screen-shot-2016-11-05-at-7-04-50-am" width="721" height="387" class="alignnone size-full wp-image-2199" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.04.50-AM.png 721w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.04.50-AM-600x322.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.04.50-AM-300x161.png 300w" sizes="auto, (max-width: 721px) 100vw, 721px" /></a></p>
<p>The robot arm has 4 &#8220;axis&#8221; which are each controlled by &#8220;servo&#8221; motors.  Servo motors have a small controller built into them that takes an input signal that is created by a PWM and turns the motor to the right place.  To drive the motor you need a input signal that is 50HZ, with a high pulse that ranges from ABOUT 1ms to 2ms.  When the pulse is 1ms the motor is all the way one direction, when the pulse is 2ms it is all the way the other direction.  To make the motor do what you want you give it a pulse somewhere in the middle, for instance if you want it to be half way then the pulse width is 1.5ms.</p>
<p>The easiest way to make this work is with a Pulse Width Modulator (PWM).  Conveniently enough, the PSoC4 BLE that I am using to build this project has 4 of them.  I set the input clock on the PWM to 12MHz, then I turned on the prescaler to divide by 4.  I then set the period to 60000.  Given all of that, the output frequency is 50hz.  which you can calculate by 12,000,000 / 4 / 60,000 = 50.  Given the period is 50HZ and there are 60000 clock ticks per period, each tick is 3us.  To make things easier on the rest of the system I want to give the input a range between 0% and 100% (as an Integer).  This lets me calculate the number of ticks I need to set the pulse width.  The formula is 3*(1000 + 10*percent).  I determined this empirically with an oscilloscope and changing the values to see the range of motion of the Robot Arm.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0012-e1478345409238.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0012-e1478345409238-225x300.jpg" alt="img_0012" width="225" height="300" class="alignnone size-medium wp-image-2204" srcset="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0012-e1478345409238-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0012-e1478345409238-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0012-e1478345409238-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0012-e1478345409238-scaled.jpg 1920w" sizes="auto, (max-width: 225px) 100vw, 225px" /></a> <a href="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0013-e1478345395205.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0013-e1478345395205-225x300.jpg" alt="img_0013" width="225" height="300" class="alignnone size-medium wp-image-2203" srcset="https://iotexpert.com/wp-content/uploads/2016/11/IMG_0013-e1478345395205-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0013-e1478345395205-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0013-e1478345395205-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2016/11/IMG_0013-e1478345395205-scaled.jpg 1920w" sizes="auto, (max-width: 225px) 100vw, 225px" /></a></p>
<p>To achieve all of this, the PWM configuration is:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.49.33-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.49.33-PM.png" alt="screen-shot-2016-11-04-at-7-49-33-pm" width="721" height="667" class="alignnone size-full wp-image-2193" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.49.33-PM.png 721w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.49.33-PM-600x555.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.49.33-PM-300x278.png 300w" sizes="auto, (max-width: 721px) 100vw, 721px" /></a></p>
<p>Now I configure the CapSense block to have a linear slider.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.52.55-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.52.55-PM.png" alt="screen-shot-2016-11-04-at-7-52-55-pm" width="869" height="577" class="alignnone size-full wp-image-2195" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.52.55-PM.png 869w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.52.55-PM-600x398.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.52.55-PM-300x199.png 300w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-04-at-7.52.55-PM-768x510.png 768w" sizes="auto, (max-width: 869px) 100vw, 869px" /></a></p>
<p>Finally I assign the pins:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.11.02-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.11.02-AM.png" alt="screen-shot-2016-11-05-at-7-11-02-am" width="680" height="270" class="alignnone size-full wp-image-2200" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.11.02-AM.png 680w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.11.02-AM-600x238.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.11.02-AM-300x119.png 300w" sizes="auto, (max-width: 680px) 100vw, 680px" /></a></p>
<p>And a little bit of firmware:</p>
<p>Line 4 is a #define macro that calculate the correct compare value for the PWM.  After a little bit of experimenting with the Robot I figured out that it really wants the PWM to range between 800 microseconds and 1.8 milliseconds.</p>
<p>Line 5-7 initialize the original position of the PWM</p>
<p>Line 15-19 and 19-23 are helper functions which just turn on and off the PWMs.</p>
<p>Line 25-34 is an interrupt handler that is trigger when the user presses the switch.  It toggles a global state variable, turns on or off the PWMs and turns on/off the led.</p>
<p>In main I get things going on lines 38-43.  Then start an infinite loop that reads the capsense, and if the value is set then I set the value for the PWMs.  Remember that the capsense slider returns a value 0-100 so I can use it directly.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.03.25-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.03.25-AM.png" alt="screen-shot-2016-11-05-at-7-03-25-am" width="742" height="962" class="alignnone size-full wp-image-2198" srcset="https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.03.25-AM.png 742w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.03.25-AM-600x778.png 600w, https://iotexpert.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-05-at-7.03.25-AM-231x300.png 231w" sizes="auto, (max-width: 742px) 100vw, 742px" /></a></p>
<p>After all of that my lab technician once again test it:</p>
<div class="jupiterx-oembed"><iframe loading="lazy" title="IOTExpert Lab Tour" width="500" height="281" src="https://www.youtube.com/embed/YnRZ5WSZDj4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/electronica-wiced-the-robot-arm/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The Creek: Testing the Bootloader</title>
		<link>https://iotexpert.com/the-creek-testing-the-firmware/</link>
					<comments>https://iotexpert.com/the-creek-testing-the-firmware/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sun, 17 Apr 2016 12:20:24 +0000</pubDate>
				<category><![CDATA[Elkhorn Creek]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=538</guid>

					<description><![CDATA[In the previous posts I described the main application firmware and the bootloader firmware.  In this post I will take you through the process of verifying that it all works.  In order to do this I need to: Test the bootloader (verify that I can bootload) Test the main application firmware (the subject of the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In the previous posts I described the main application firmware and the bootloader firmware.  In this post I will take you through the process of verifying that it all works.  In order to do this I need to:</p>
<ol>
<li>Test the bootloader (verify that I can bootload)</li>
<li>Test the main application firmware (the subject of the next post)
<ul>
<li>Verify the pressure sensor</li>
<li>Verify the temperature sensor</li>
<li>Verify the I2C communication</li>
</ul>
</li>
</ol>
<h2>Testing Bootloader</h2>
<p>Cypress makes a cool programming tool called the MiniProg-3 which we also call <a href="http://www.cypress.com/documentation/development-kitsboards/cy8ckit-002-psoc-miniprog3-program-and-debug-kit">CY8CKIT-002</a>.  The MP3 is a multi purpose tool that can be use to:</p>
<ul>
<li>Program and debug Cypress PSoC chips</li>
<li>Bridge USB &lt;-&gt; I2C (which I will use to test the firmware)</li>
<li>Bridge USB &lt;-&gt; JTAG</li>
<li>Bridge USB &lt;-&gt; ISSP</li>
</ul>
<p>First, I will program the bootloader firmware using PSoC Creator connected via USB to a MP3.  In the photograph below you can see:</p>
<ul>
<li>Mini Prog 3</li>
<li>The CYPI Bridge Board with the PSoC 4</li>
<li>The 10-pin ARM programming header (which is attached to the grey cable from the MP3)</li>
<li>The blue blinking LED.  (after I programmed the board the LED started blinking.  In this picture I caught it on)</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/IMG_2727.jpg"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-695" src="https://iotexpert.com/wp-content/uploads/2016/03/IMG_2727-1024x768.jpg" alt="Programming the bootloader" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2016/03/IMG_2727-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2016/03/IMG_2727-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/03/IMG_2727-300x225.jpg 300w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>At this point it appears that the bootloader is programmed into PSoC4 as the LED is blinking.  In this case I only programmed the bootloader, so there is no application firmware to jump to, so the chip will just keep running the bootloader until the power goes off.</p>
<p>Next, I need to attach another MP3 acting in the role of a USB &lt;&#8211;&gt; I2C bridge.  The MP3 will emulate the Raspberry Pi which will be used in the production system, but for now it is easier to test without the added complexity of the RPi.  I am using one MP3 just as a power source for the CYPI board (I could have just plugged in a wall wart).  You can see that I have two wires, one for SDA and one for SCL connected to the correct RPi/CYPI pin.  The other side of the wires are sticking into the correct female connectors on the header of the MP3 (right next to each other at the bottom).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/IMG_2728.jpg"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-698" src="https://iotexpert.com/wp-content/uploads/2016/03/IMG_2728-1024x768.jpg" alt="IMG_2728" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2016/03/IMG_2728-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2016/03/IMG_2728-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/03/IMG_2728-300x225.jpg 300w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Then I start the bootloader host which is a program that can read CYACD files (which is just a format of a hex file) and send it out over I2C (or UART) using the bootloading protocol.  First, I select the correct CYACD file from the directory where PSoC Creator put it.  Then I click the download button.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderHost-a.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-699" src="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderHost-a.png" alt="BootloaderHost-a" width="543" height="560" srcset="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderHost-a.png 543w, https://iotexpert.com/wp-content/uploads/2016/03/BootloaderHost-a-291x300.png 291w" sizes="auto, (max-width: 543px) 100vw, 543px" /></a></p>
<p>A few seconds after the boot loading is finished, the blinking blue led turns off and a blinking red led starts.  This indicates that the main application firmware is running.  To verify that the bootloader still works I press the reset switch on the board and the blue led starts blinking for 10 seconds before jumping back into the application firmware.  Good.  The bootloader and application firmware work together correctly.</p>
<p>In the next post I will show you how to use the Bridge Control Panel to verify that the firmware is working correctly.</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Index</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a class="row-title" href="https://iotexpert.com/2016/01/25/the-elkhorn-creek/" title="Edit “The Creek: IOT for the Elkhorn Creek”">The Creek: IOT for the Elkhorn Creek</a></td>
<td >Introduction</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/01/30/creek-architecture-1-0/" title="Edit “The Creek: Solution Architecture 1.0”">The Creek: Solution Architecture 1.0</a></td>
<td >Overall architecture</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/07/the-creek-board-1-1/" title="Edit “The Creek: Creek Board 1.1”">The Creek: Creek Board 1.1</a></td>
<td >Eagle layout of the board</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/14/creek-board-1-0-rcca/" title="Edit “The Creek: Creek Board 1.0 – RCCA”">The Creek: Creek Board 1.0 – RCCA</a></td>
<td >A discussion of the errors in the 1.0 board</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/21/cypi/" title="Edit “The Creek: CYPI</td>
<td > a Raspberry Pi to Arduino Bridge”">The Creek: CYPI, a Raspberry Pi to Arduino Bridge</a></td>
<td > PSoC4 &lt;--&gt; Raspberry Pi Bridge Board</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/03/26/the-creek-psoc-4-creator-schematic-firmware/">The Creek: PSoC4 Creator Schematic and Firmware</a></td>
<td > Firmware to interface with the temperature and pressure sensors</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/10/the-creek-testing-the-firmware-2/">The Creek: Testing the Firmware</a></td>
<td > Using tools to verify that the PSoC 4 Firmware is working correctly</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/17/the-creek-testing-the-firmware/">The Creek: Testing the Bootloader</a></td>
<td > Make sure that you can load new firmware into the PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/24/the-creek-server-software-architecture/">The Creek: Software Architecture</a></td>
<td >All of the Raspberry Pi software connections</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/19/the-creek-install-mysql/">The Creek: Install MySql</a></td>
<td >Instruction to configure MySql</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/10/the-creek-install-tomcat/">The Creek: Install Tomcat</a></td>
<td >Instruction to configure Tomcat JSP Server</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/26/the-creek-collect-data-part-1/">The Creek: Data Collection Java (Part 1)</a></td>
<td >The Java program that reads the I2C and saves it in the database</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/03/the-creek-collect-data-part-2/">The Creek: Data Collection Java (Part 2)</a></td>
<td >The Java program that reads the I2C and saves it in the database</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/17/the-creek-create-the-chart-with-jfreechart/">The Creek: Create the Chart with JFreeChart</a></td>
<td >Using open source Java charting software to create plots of the Creek Depth</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/31/the-creek-flood-event-data-processor/">The Creek: Flood Event Data Processor</a></td>
<td >A batch program to create analyze the database and create a table of flood events</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/31/the-creek-flood-event-web-page/">The Creek: Flood Event Web Page</a></td>
<td > A batch program to create the flood event web page</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/07/the-creek-creek-server-1-1/">The Creek: Creek Server 1.1</a></td>
<td >Updates to all of the back off server programs to integrate charts</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/14/the-creek-web-pages-with-java-server-pages-jsp/">The Creek: JSP Web Page for www.elkhorn-creek.org</a></td>
<td >The JSP program to make the table and display the website</td>
</tr>

<tr><td >The Creek: Raspberry Pi Clock Stretching</td>
<td >Sorting out a bug in the system having to do with the Broadcomm Raspberry Pi Master not functioning well with clock stretching</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/28/the-creek-creek-server-1-2/">The Creek: Creek Server 1.2</a></td>
<td >Caching the web pages to make them faster</td>
</tr>
</tbody></table></div></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/the-creek-testing-the-firmware/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The Creek: Testing the Firmware</title>
		<link>https://iotexpert.com/the-creek-testing-the-firmware-2/</link>
					<comments>https://iotexpert.com/the-creek-testing-the-firmware-2/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sun, 10 Apr 2016 11:36:41 +0000</pubDate>
				<category><![CDATA[Elkhorn Creek]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=707</guid>

					<description><![CDATA[In the previous post I discussed the process that I used to test the bootloader firmware.  In this post I will walk you through testing the actual application firmware.  As I started working on this post I decided to remind myself of the format of the EZI2C buffer.  Here it is: The first thing that I [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In the previous post I discussed the process that I used to test the bootloader firmware.  In this post I will walk you through testing the actual application firmware.  As I started working on this post I decided to remind myself of the format of the EZI2C buffer.  Here it is:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/DataPacketFormat.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-722" src="https://iotexpert.com/wp-content/uploads/2016/03/DataPacketFormat.png" alt="DataPacketFormat" width="466" height="115" srcset="https://iotexpert.com/wp-content/uploads/2016/03/DataPacketFormat.png 466w, https://iotexpert.com/wp-content/uploads/2016/03/DataPacketFormat-300x74.png 300w" sizes="auto, (max-width: 466px) 100vw, 466px" /></a></p>
<p>The first thing that I immediately noticed was that I did something really dumb.  Specifically I named one of the fields &#8220;float pressure&#8221; when it is really &#8220;float inches&#8221;. Oh well.  The DataPacket structure is composed of 4 variables, two of them are 2-byte unsigned integers and two of them are 4-byte float.  As this PSoC is an ARM chip, all of the variables are stored in little endian format-meaning that the Most Significant Byte (MSB) is last.</p>
<p>To help test the firmware, I will use a program called the Bridge Control Panel (BCP).  The BCP is delivered as part of the PSoC Creator installation and is available under the Start-&gt;All Programs-&gt;Cypress menu.  The BCP can talk to a Miniprog 3 (or any of the Cypress programmers) via the USB port and then bridge to the I2C bus.  It can then act as an I2C master- in my case it will be emulating the Raspberry Pi I2C Master.</p>
<p>After starting the BCP, I first configure the &#8220;chart-&gt;variable settings&#8221;.  This allows me to setup names and sizes of the EZI2C registers that I want to read from the PSoC.  You can see that I added one variable to correspond to each variable in the DataPacket structure.  In the BCP, an &#8220;int&#8221; is the same as an ARM int16 aka a two byte integer.  I also select &#8220;sign&#8221; to indicate that the tempCenti is int16 (not uint16).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/bcpVariableSetup.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-721" src="https://iotexpert.com/wp-content/uploads/2016/03/bcpVariableSetup.png" alt="bcpVariableSetup" width="523" height="414" srcset="https://iotexpert.com/wp-content/uploads/2016/03/bcpVariableSetup.png 523w, https://iotexpert.com/wp-content/uploads/2016/03/bcpVariableSetup-300x237.png 300w" sizes="auto, (max-width: 523px) 100vw, 523px" /></a></p>
<p>After setting up the variables, I first make sure that the BCP is talking to the PSoC4 by pressing &#8220;list&#8221; button on the BCP.  When I click that button, the BCP tries to read from all of the 127 valid I2C addresses.  If it gets an &#8220;ACK&#8221;, then it reports that it can talk to that device.  On the screen below you can see that it sees &#8220;address: 10 08&#8221; which is the I2C address of my PSoC4.</p>
<p>The next step is to tell the BCP how to read the EZI2C registers.  First I write a 0 to address 8 with the &#8220;w 8 0;&#8221; command.  This sets the &#8220;data pointer&#8221; t0 0, meaning the start of the register space.  I then issue command to read 12 bytes, each byte has a name that corresponds to a byte in the &#8220;variables&#8221; configured in the previous step.  An example is &#8220;@0presscount&#8221; which corresponds to the least significant byte of the presscount variable and &#8220;@1presscount&#8221; which corresponds to the most significant byte of the presscount variable.</p>
<p>After setting up the variables, I press &#8220;return&#8221; to issue the command.  The BCP returns &#8220;r 08+ 00+ 00+ AC+ 08+ 8A+ E4+ D0+ C2+ 9A+ 99+ B1+ 41+&#8221;.  What does that mean? The R means that it did a read.  The 08+ is the address of the I2C and the + means and &#8220;ACK&#8221;.  Each of the other bytes+ are the other 12 bytes read in the command.  I use this <a href="http://babbage.cs.qc.cuny.edu/IEEE-754.old/32bit.html">website</a> to covert the 4-byte hex float(s) to decimal and I get:</p>
<ul>
<li>pressCount = 0x0000 : There is 0 volts attached to the input which is true</li>
<li>tempCenti = 0x08AC = 2200 (that makes sense 22.2 degrees c * 100 ~= 2200)</li>
<li>pressure = 0xC2D0E48A = -104.44636535644531 &#8230; that makes sense rememberdp.pressure = (((float)dp.pressureCounts)-408)/3.906311:</li>
<li>temp = 0x41b1999A = 22.200000762939453 c = 71.9f [ok that makes sense]</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/bcpMainScreen.png"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-718" src="https://iotexpert.com/wp-content/uploads/2016/03/bcpMainScreen-1024x612.png" alt="bcpMainScreen" width="1024" height="612" srcset="https://iotexpert.com/wp-content/uploads/2016/03/bcpMainScreen-1024x612.png 1024w, https://iotexpert.com/wp-content/uploads/2016/03/bcpMainScreen-600x358.png 600w, https://iotexpert.com/wp-content/uploads/2016/03/bcpMainScreen-300x179.png 300w, https://iotexpert.com/wp-content/uploads/2016/03/bcpMainScreen.png 1341w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The next step is to attach a bench power supply to the pressure input (I bought this one from eBay).  I will use the variable voltage to simulate different pressures.  Recall from the schematic that the pressure sensor acts as a current source that is then driven into a 51.1 ohm resistor.  Here is the schematic:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/pressureSchematic.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-726" src="https://iotexpert.com/wp-content/uploads/2016/03/pressureSchematic.png" alt="pressureSchematic" width="464" height="351" srcset="https://iotexpert.com/wp-content/uploads/2016/03/pressureSchematic.png 464w, https://iotexpert.com/wp-content/uploads/2016/03/pressureSchematic-300x227.png 300w" sizes="auto, (max-width: 464px) 100vw, 464px" /></a></p>
<p>With this setup if I put in 0.51V on the &#8220;high side&#8221; I should get [V=IR] 0.51V = I * 51.1Ohm so I= 0.01 A.  You can see from the picture that is what I get (or pretty damn close).  When I press return on the bridge control panel (see it in the screen shot above) I get &#8220;r 08+ E4+ 03+ C0+ 08+ 91+ 86+ 16+ 43+ 33+ 33+ B3+ 41+&#8221; which means</p>
<ul>
<li>pressCount = 0x03E4 = 996 counts.  The range of the ADC is 4096 counts (in single ended mode)  and 0 &#8211;&gt; 2.048V so 996 counts is 0.498v</li>
<li>tempCenti = 0x08C0 = 2200 (that makes sense 22.2 degrees c * 100 ~= 2200)</li>
<li>pressure = 0x43168691 =  150.52565002441406 [that works&#8230; remember the equation]dp.pressure = (((float)dp.pressureCounts)-408)/3.906311</li>
<li>temp = 0x41B33333 = 22.399999618530273 c = 72.3f [ok that makes sense]</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/pressure-05volt.jpg"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-719" src="https://iotexpert.com/wp-content/uploads/2016/03/pressure-05volt-1024x768.jpg" alt="pressure-05volt" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2016/03/pressure-05volt-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2016/03/pressure-05volt-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/03/pressure-05volt-300x225.jpg 300w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>For the last test of the pressure sensor input I put the variable supply to 1.0V which makes 0.019 mA.  Once again V=IR 1V/51.1Ohm = 0.0196 A.  Ok Ohms law still works.  Then I press return and I get &#8220;r 08+ 98+ 07+ C0+ 08+ DD+ 9A+ C4+ 43+ 33+ 33+ B3+ 41+ p&#8221;.  When I decode that I get</p>
<ul>
<li>pressCount = 0x0798 = 1944 counts.  The range of the ADC is 4096 counts (in single ended mode)  and 0 &#8211;&gt; 2.048V so 1944 counts is 0.972v (that is pretty damn close)</li>
<li>tempCenti = 0x08C0 = 2240 (that makes sense 22.4 degrees c * 100 ~= 2240)</li>
<li>pressure = 0x43C49ADD = 393.2098693847656 [that works&#8230; remember the equation]dp.pressure = (((float)dp.pressureCounts)-408)/3.906311:</li>
<li>temp = 0x41B33333 = 22.399999618530273 c = 72.3f [ok that makes sense]</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/Pressure1v.jpg"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-720" src="https://iotexpert.com/wp-content/uploads/2016/03/Pressure1v-1024x768.jpg" alt="Pressure1v" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2016/03/Pressure1v-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2016/03/Pressure1v-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/03/Pressure1v-300x225.jpg 300w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>In the next test I will go into graphing mode and use the &#8220;repeat&#8221; button to run I2C reads as fast as possible.  I will then sweep the voltage on the bench power supply and plot the pressure and the counts to make sure that makes sense.  It looks good, here is the plot:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphofPressure.png"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-717" src="https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphofPressure-1024x614.png" alt="bcpGraphofPressure" width="1024" height="614" srcset="https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphofPressure-1024x614.png 1024w, https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphofPressure-600x360.png 600w, https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphofPressure-300x180.png 300w, https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphofPressure.png 1342w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>In the next test I use a Fluke Thermocouple to verify that the TMP036 is reading the correct temperature.  You can see that when I put the thermocouple right on the sensor it reads 23.4 degrees C.  I then turned the camera towards the screen and took a picture of the plot.  In that plot you can see the temperature bouncing around 22.5.  The bounce is  +- 1 count (literally noise) of the ADC .  I am not sure what the cause of the 0.9 degree difference between the Fluke and the TMP036, it could be several things including the accuracy of the TMP036, the accuracy of the Fluke, the accuracy of the PSoC4 ADC, where I am measuring, etc.  But less than a degree really doesn&#8217;t matter to me.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/temp-fluke.jpg"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-715" src="https://iotexpert.com/wp-content/uploads/2016/03/temp-fluke-1024x768.jpg" alt="temp-fluke" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2016/03/temp-fluke-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2016/03/temp-fluke-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/03/temp-fluke-300x225.jpg 300w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/temp-bcp.jpg"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-714" src="https://iotexpert.com/wp-content/uploads/2016/03/temp-bcp-1024x768.jpg" alt="temp-bcp" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2016/03/temp-bcp-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2016/03/temp-bcp-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/03/temp-bcp-300x225.jpg 300w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>In the last test I make a graph of the temperature while I am grabbing the TMP036 which causes the temperature to rise.  After a bit of time I let go of the sensor and you can see the temperature fall.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphOfTemperature.png"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-716" src="https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphOfTemperature-1024x612.png" alt="bcpGraphOfTemperature" width="1024" height="612" srcset="https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphOfTemperature-1024x612.png 1024w, https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphOfTemperature-600x359.png 600w, https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphOfTemperature-300x179.png 300w, https://iotexpert.com/wp-content/uploads/2016/03/bcpGraphOfTemperature.png 1342w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>At this point it looks like the bootloader is working and that the PSoC 4 firmware is working.  In the next post I will talk about the overall server software architecture.</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Index</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a class="row-title" href="https://iotexpert.com/2016/01/25/the-elkhorn-creek/" title="Edit “The Creek: IOT for the Elkhorn Creek”">The Creek: IOT for the Elkhorn Creek</a></td>
<td >Introduction</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/01/30/creek-architecture-1-0/" title="Edit “The Creek: Solution Architecture 1.0”">The Creek: Solution Architecture 1.0</a></td>
<td >Overall architecture</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/07/the-creek-board-1-1/" title="Edit “The Creek: Creek Board 1.1”">The Creek: Creek Board 1.1</a></td>
<td >Eagle layout of the board</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/14/creek-board-1-0-rcca/" title="Edit “The Creek: Creek Board 1.0 – RCCA”">The Creek: Creek Board 1.0 – RCCA</a></td>
<td >A discussion of the errors in the 1.0 board</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/21/cypi/" title="Edit “The Creek: CYPI</td>
<td > a Raspberry Pi to Arduino Bridge”">The Creek: CYPI, a Raspberry Pi to Arduino Bridge</a></td>
<td > PSoC4 &lt;--&gt; Raspberry Pi Bridge Board</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/03/26/the-creek-psoc-4-creator-schematic-firmware/">The Creek: PSoC4 Creator Schematic and Firmware</a></td>
<td > Firmware to interface with the temperature and pressure sensors</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/10/the-creek-testing-the-firmware-2/">The Creek: Testing the Firmware</a></td>
<td > Using tools to verify that the PSoC 4 Firmware is working correctly</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/17/the-creek-testing-the-firmware/">The Creek: Testing the Bootloader</a></td>
<td > Make sure that you can load new firmware into the PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/24/the-creek-server-software-architecture/">The Creek: Software Architecture</a></td>
<td >All of the Raspberry Pi software connections</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/19/the-creek-install-mysql/">The Creek: Install MySql</a></td>
<td >Instruction to configure MySql</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/10/the-creek-install-tomcat/">The Creek: Install Tomcat</a></td>
<td >Instruction to configure Tomcat JSP Server</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/26/the-creek-collect-data-part-1/">The Creek: Data Collection Java (Part 1)</a></td>
<td >The Java program that reads the I2C and saves it in the database</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/03/the-creek-collect-data-part-2/">The Creek: Data Collection Java (Part 2)</a></td>
<td >The Java program that reads the I2C and saves it in the database</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/17/the-creek-create-the-chart-with-jfreechart/">The Creek: Create the Chart with JFreeChart</a></td>
<td >Using open source Java charting software to create plots of the Creek Depth</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/31/the-creek-flood-event-data-processor/">The Creek: Flood Event Data Processor</a></td>
<td >A batch program to create analyze the database and create a table of flood events</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/31/the-creek-flood-event-web-page/">The Creek: Flood Event Web Page</a></td>
<td > A batch program to create the flood event web page</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/07/the-creek-creek-server-1-1/">The Creek: Creek Server 1.1</a></td>
<td >Updates to all of the back off server programs to integrate charts</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/14/the-creek-web-pages-with-java-server-pages-jsp/">The Creek: JSP Web Page for www.elkhorn-creek.org</a></td>
<td >The JSP program to make the table and display the website</td>
</tr>

<tr><td >The Creek: Raspberry Pi Clock Stretching</td>
<td >Sorting out a bug in the system having to do with the Broadcomm Raspberry Pi Master not functioning well with clock stretching</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/28/the-creek-creek-server-1-2/">The Creek: Creek Server 1.2</a></td>
<td >Caching the web pages to make them faster</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/the-creek-testing-the-firmware-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The Creek: PSoC 4 Bootloader Schematic + Firmware</title>
		<link>https://iotexpert.com/the-creek-psoc-4-bootloader-schematic-firmware/</link>
					<comments>https://iotexpert.com/the-creek-psoc-4-bootloader-schematic-firmware/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sun, 03 Apr 2016 10:14:07 +0000</pubDate>
				<category><![CDATA[Elkhorn Creek]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=559</guid>

					<description><![CDATA[A bootloader is a firmware program that can update the application firmware in an embedded system without using a programmer (like the Miniprog-3).  This is a convienient way to fix bugs, release features, etc. without having to be physically at the system.  As a developer you can update your design, then create a &#8220;hex&#8221; file image, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>A bootloader is a firmware program that can update the application firmware in an embedded system without using a programmer (like the Miniprog-3).  This is a convienient way to fix bugs, release features, etc. without having to be physically at the system.  As a developer you can update your design, then create a &#8220;hex&#8221; file image, then release that image (through email, the internet, etc) to be installed on all of your remote devices.  Once your new hex file arrives at the host computer, the bootloader has the job of flashing the new firmware into your system.  You can read more detail about bootloading in the excellent Cypress application note <a href="http://www.cypress.com/documentation/application-notes/an86526-psoc-4-i2c-bootloader?source=search&amp;keywords=bootloader" target="_blank">AN86526 PSoC4 I2C Bootloader</a>.</p>
<p>In general, bootloaders are triggered by some external event (like a chip reset, a trigger from a GPIO, or a command from the application firmware).  The bootloader then listens for communication from a host computer.  The host computer could be lots of different things including a cell phone, a central application processor, or an external computer plugged into your system.  Once the bootloader starts:</p>
<ul>
<li>If there is no communication it will generally timeout after a set time, then jump into the application firmware to put the system into normal application mode.</li>
<li>If there is communication, it will copy a new application from the host computer and then write it into the flash in the correct place.  There is a special case called a &#8220;dual application&#8221; boot loader.  This provides safety by keeping and old image still in flash in case there is a problem bootloading the new firmware.</li>
</ul>
<p>Here is a picture of the architecture:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/02/bootloading.png"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-675" src="https://iotexpert.com/wp-content/uploads/2016/02/bootloading-1024x609.png" alt="bootloading" width="1024" height="609" srcset="https://iotexpert.com/wp-content/uploads/2016/02/bootloading-1024x609.png 1024w, https://iotexpert.com/wp-content/uploads/2016/02/bootloading-600x357.png 600w, https://iotexpert.com/wp-content/uploads/2016/02/bootloading-300x179.png 300w, https://iotexpert.com/wp-content/uploads/2016/02/bootloading.png 1198w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>In the Cypress language the bootloadable is an application image that can be bootloaded by the bootloader.</p>
<p>When I am making firmware like this I generally put two projects in the same workspace.  One project is the bootloader and the other project is the bootloadable. This is exactly what you will find in in the PSoC Creator workspace called <a href="https://github.com/alanhawse/ElkhornCreek" target="_blank">CreekFirmware</a> on github.  The first project is called p4arduino-creek which is the main application firmware that  I discussed in detail in the previous post.</p>
<p>This bootloader, called p4bootloader, is a simple I2C bootloader.  After the chip resets it:</p>
<ul>
<li>Starts blinking the blue led to indicate that it is in bootloader mode</li>
<li>Waits 10 seconds to hear I2C communication</li>
<li>If there is none then it jumps into the main application (called the bootloadable)</li>
<li>It there is then it starts the boot loading process</li>
</ul>
<p>The schematic is simply:</p>
<ul>
<li>An I2C Slave</li>
<li>A bootloader component</li>
<li>A blinking LED (a clock tied directly to an output pin)</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderSchematic.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-681" src="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderSchematic.png" alt="BootloaderSchematic" width="415" height="653" srcset="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderSchematic.png 415w, https://iotexpert.com/wp-content/uploads/2016/03/BootloaderSchematic-191x300.png 191w" sizes="auto, (max-width: 415px) 100vw, 415px" /></a></p>
<p>When you configure the bootloader component you need to select which communication interface to use.  In this case it is the &#8220;I2C&#8221;.  Then you configure how long you want to wait before timing out and jumping into the main application.  In this case 10000ms a.k.a. 10s</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderConfiguration.png"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-682" src="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderConfiguration.png" alt="BootloaderConfiguration" width="642" height="499" srcset="https://iotexpert.com/wp-content/uploads/2016/03/BootloaderConfiguration.png 642w, https://iotexpert.com/wp-content/uploads/2016/03/BootloaderConfiguration-600x466.png 600w, https://iotexpert.com/wp-content/uploads/2016/03/BootloaderConfiguration-300x233.png 300w" sizes="auto, (max-width: 642px) 100vw, 642px" /></a></p>
<p>The last step is to start the bootloader component in the firmware.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/03/BootloadingFirmware.png"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-683" src="https://iotexpert.com/wp-content/uploads/2016/03/BootloadingFirmware.png" alt="BootloadingFirmware" width="804" height="482" srcset="https://iotexpert.com/wp-content/uploads/2016/03/BootloadingFirmware.png 804w, https://iotexpert.com/wp-content/uploads/2016/03/BootloadingFirmware-600x360.png 600w, https://iotexpert.com/wp-content/uploads/2016/03/BootloadingFirmware-300x180.png 300w" sizes="auto, (max-width: 804px) 100vw, 804px" /></a></p>
<p>That is it.  In the next post I will discuss the steps I took to test the firmware.</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Index</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a class="row-title" href="https://iotexpert.com/2016/01/25/the-elkhorn-creek/" title="Edit “The Creek: IOT for the Elkhorn Creek”">The Creek: IOT for the Elkhorn Creek</a></td>
<td >Introduction</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/01/30/creek-architecture-1-0/" title="Edit “The Creek: Solution Architecture 1.0”">The Creek: Solution Architecture 1.0</a></td>
<td >Overall architecture</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/07/the-creek-board-1-1/" title="Edit “The Creek: Creek Board 1.1”">The Creek: Creek Board 1.1</a></td>
<td >Eagle layout of the board</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/14/creek-board-1-0-rcca/" title="Edit “The Creek: Creek Board 1.0 – RCCA”">The Creek: Creek Board 1.0 – RCCA</a></td>
<td >A discussion of the errors in the 1.0 board</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/21/cypi/" title="Edit “The Creek: CYPI</td>
<td > a Raspberry Pi to Arduino Bridge”">The Creek: CYPI, a Raspberry Pi to Arduino Bridge</a></td>
<td > PSoC4 &lt;--&gt; Raspberry Pi Bridge Board</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/03/26/the-creek-psoc-4-creator-schematic-firmware/">The Creek: PSoC4 Creator Schematic and Firmware</a></td>
<td > Firmware to interface with the temperature and pressure sensors</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/10/the-creek-testing-the-firmware-2/">The Creek: Testing the Firmware</a></td>
<td > Using tools to verify that the PSoC 4 Firmware is working correctly</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/17/the-creek-testing-the-firmware/">The Creek: Testing the Bootloader</a></td>
<td > Make sure that you can load new firmware into the PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/24/the-creek-server-software-architecture/">The Creek: Software Architecture</a></td>
<td >All of the Raspberry Pi software connections</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/19/the-creek-install-mysql/">The Creek: Install MySql</a></td>
<td >Instruction to configure MySql</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/10/the-creek-install-tomcat/">The Creek: Install Tomcat</a></td>
<td >Instruction to configure Tomcat JSP Server</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/26/the-creek-collect-data-part-1/">The Creek: Data Collection Java (Part 1)</a></td>
<td >The Java program that reads the I2C and saves it in the database</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/03/the-creek-collect-data-part-2/">The Creek: Data Collection Java (Part 2)</a></td>
<td >The Java program that reads the I2C and saves it in the database</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/17/the-creek-create-the-chart-with-jfreechart/">The Creek: Create the Chart with JFreeChart</a></td>
<td >Using open source Java charting software to create plots of the Creek Depth</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/31/the-creek-flood-event-data-processor/">The Creek: Flood Event Data Processor</a></td>
<td >A batch program to create analyze the database and create a table of flood events</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/31/the-creek-flood-event-web-page/">The Creek: Flood Event Web Page</a></td>
<td > A batch program to create the flood event web page</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/07/the-creek-creek-server-1-1/">The Creek: Creek Server 1.1</a></td>
<td >Updates to all of the back off server programs to integrate charts</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/14/the-creek-web-pages-with-java-server-pages-jsp/">The Creek: JSP Web Page for www.elkhorn-creek.org</a></td>
<td >The JSP program to make the table and display the website</td>
</tr>

<tr><td >The Creek: Raspberry Pi Clock Stretching</td>
<td >Sorting out a bug in the system having to do with the Broadcomm Raspberry Pi Master not functioning well with clock stretching</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/28/the-creek-creek-server-1-2/">The Creek: Creek Server 1.2</a></td>
<td >Caching the web pages to make them faster</td>
</tr>
</tbody></table></div></p> </span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/the-creek-psoc-4-bootloader-schematic-firmware/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>The Creek: PSoC 4 Creator Schematic + Firmware</title>
		<link>https://iotexpert.com/the-creek-psoc-4-creator-schematic-firmware/</link>
					<comments>https://iotexpert.com/the-creek-psoc-4-creator-schematic-firmware/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sat, 26 Mar 2016 12:21:53 +0000</pubDate>
				<category><![CDATA[Elkhorn Creek]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=443</guid>

					<description><![CDATA[In this post I will describe the PSoC Creator schematic and firmware that I built to run the PSoC4.  You can find the project on github.  After you open the project in PSoC Creator you will find two projects in the workspace explorer: p4ardino-creek: This project starts running 10 seconds after the chip powers up.  It uses [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post I will describe the PSoC Creator schematic and firmware that I built to run the PSoC4.  You can find the project on <a href="https://github.com/iotexpert/TheCreek">github</a>.  After you open the project in PSoC Creator you will find two projects in the workspace explorer:</p>
<ol>
<li><strong>p4ardino-creek:</strong> This project starts running 10 seconds after the chip powers up.  It uses PSoC Analog to Digital Convertor to read the pressure sensor and the temperature sensor.  It then convert the data to a readable form and stores it into the EZI2C buffer to be read by the Raspberry PI.</li>
<li><strong>p4bootloader:</strong> This project runs for 10 seconds when the chip is rebooted.  If it detects the Raspberry Pi host trying to load new firmware it will &#8220;bootload&#8221;.  If after 10 seconds it doesn&#8217;t hear anything, it will run the p4arduino-creek application.  I will describe how the bootloader works in the next post.</li>
</ol>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/02/CreekWorkspace.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-552" src="https://iotexpert.com/wp-content/uploads/2016/02/CreekWorkspace.png" alt="CreekWorkspace" width="363" height="378" srcset="https://iotexpert.com/wp-content/uploads/2016/02/CreekWorkspace.png 363w, https://iotexpert.com/wp-content/uploads/2016/02/CreekWorkspace-288x300.png 288w" sizes="auto, (max-width: 363px) 100vw, 363px" /></a></p>
<h1>p4ardunio-creek</h1>
<p>The schematic for this project contains four sections</p>
<ol>
<li>The Analog to Digital convertor and the &#8220;external&#8221; schematic of the pressure current loop.  The elements in blue are external to the PSoC and are there just for documentation.</li>
<li>The Red and Blue LED pins and the clock that drives the Red LED to blink</li>
<li>The EZI2C which serves as the I2C Slave for the Raspberry Pi to read</li>
<li>The Bootloadable component which allows this project to be boot loaded.</li>
</ol>
<p>The configuration of each of elements is show below.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-553" src="https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic.png" alt="Creek Schematic" width="902" height="666" srcset="https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic.png 902w, https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic-600x443.png 600w, https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic-300x222.png 300w" sizes="auto, (max-width: 902px) 100vw, 902px" /></a></p>
<p>The ADC is configured to run as slowly as possible (1000 SPS).  I have also enabled the averaging which automatically averages 256 samples.  This effectively makes a low pass filter to remove noise.  This is possible because the pressure and temperature move very slowly as compared to the speed at which they are sampled.  The SAR ADC in the PSoC is inherently differential, I tell the ADC that I want the negative channel to be connected to a stable VREF.  This allows me to measure between 0V and 2*vref = 2.048 volts.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen1.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-525" src="https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen1.png" alt="ADC Configuration 1" width="876" height="639" srcset="https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen1.png 876w, https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen1-600x438.png 600w, https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen1-300x219.png 300w" sizes="auto, (max-width: 876px) 100vw, 876px" /></a></p>
<p>On the ADC channels TAB I enable two channels, both single ended, both with averaging turned on.  Channel 0 is connected to the pressure sensor (on Arduino pin A0 = PSoC Pin P2[0]) and channel 1 is connected to the TMP036 (on Arduino pin A1 = PSoC Pin P2[1])</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen2.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-526" src="https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen2.png" alt="ADC Configuration Screen 2" width="872" height="641" srcset="https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen2.png 872w, https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen2-600x441.png 600w, https://iotexpert.com/wp-content/uploads/2016/01/CreekAdcScreen2-300x221.png 300w" sizes="auto, (max-width: 872px) 100vw, 872px" /></a></p>
<p>For this design I setup the PSoC4 to act as an EZI2C slave.  EZI2C means that the chip follows the EEPROM protocol which many many I2C masters understand.  The only thing that I configure in this case is to use the slave address of 0X08.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/01/CreekEzI2C.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-527" src="https://iotexpert.com/wp-content/uploads/2016/01/CreekEzI2C.png" alt="CreekEzI2C" width="633" height="474" srcset="https://iotexpert.com/wp-content/uploads/2016/01/CreekEzI2C.png 633w, https://iotexpert.com/wp-content/uploads/2016/01/CreekEzI2C-600x449.png 600w, https://iotexpert.com/wp-content/uploads/2016/01/CreekEzI2C-300x225.png 300w" sizes="auto, (max-width: 633px) 100vw, 633px" /></a></p>
<p>For this project to be compatible with a bootloader it needs the bootloadble component instantiated.  In this case I use all of the default configurations.  When I make changes to the firmware in the future I will up-rev the version numbers.  These settings are here to prevent you from accidentally overwriting and newer rev of the firmware or putting in the wrong application type.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/01/CreekBootLoadableConfig.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-528" src="https://iotexpert.com/wp-content/uploads/2016/01/CreekBootLoadableConfig.png" alt="CreekBootLoadableConfig" width="506" height="387" srcset="https://iotexpert.com/wp-content/uploads/2016/01/CreekBootLoadableConfig.png 506w, https://iotexpert.com/wp-content/uploads/2016/01/CreekBootLoadableConfig-300x229.png 300w" sizes="auto, (max-width: 506px) 100vw, 506px" /></a></p>
<p>In order for the bootloadable to work I need to tell it where its  &#8220;bootloader&#8221; image resides.  Remember from above that I put both projects in the same workspace.  So, what I need to do is browse through the directory hierarchy into the bootloader project and selects its ELF and HEX files.  If you want to read more about PSoC4 Bootloading you can read <a href="http://www.cypress.com/documentation/application-notes/an86526-psoc-4-i2c-bootloader">AN86526</a> entitled &#8220;PSoC 4 I2C Bootloader&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/01/BootloableDependencies.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-529" src="https://iotexpert.com/wp-content/uploads/2016/01/BootloableDependencies.png" alt="BootloableDependencies" width="751" height="366" srcset="https://iotexpert.com/wp-content/uploads/2016/01/BootloableDependencies.png 751w, https://iotexpert.com/wp-content/uploads/2016/01/BootloableDependencies-600x292.png 600w, https://iotexpert.com/wp-content/uploads/2016/01/BootloableDependencies-300x146.png 300w" sizes="auto, (max-width: 751px) 100vw, 751px" /></a></p>
<p>One of the unique features of a PSoC is its ability to do hardware based design.  In this design I want a slowly blinking LED to indicate that the system is running.  For this task I have to configure the pin to let one of the internal clocks drive it.  To make this work you need to selected the output mode as &#8220;Clock&#8221;.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/02/redLedPin.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-540" src="https://iotexpert.com/wp-content/uploads/2016/02/redLedPin.png" alt="redLedPin" width="629" height="476" srcset="https://iotexpert.com/wp-content/uploads/2016/02/redLedPin.png 629w, https://iotexpert.com/wp-content/uploads/2016/02/redLedPin-600x454.png 600w, https://iotexpert.com/wp-content/uploads/2016/02/redLedPin-300x227.png 300w" sizes="auto, (max-width: 629px) 100vw, 629px" /></a></p>
<p>And you need to selected the &#8220;Out clock&#8221; as external.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/02/redLedClock.png"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-541" src="https://iotexpert.com/wp-content/uploads/2016/02/redLedClock.png" alt="redLedClock" width="633" height="472" srcset="https://iotexpert.com/wp-content/uploads/2016/02/redLedClock.png 633w, https://iotexpert.com/wp-content/uploads/2016/02/redLedClock-600x447.png 600w, https://iotexpert.com/wp-content/uploads/2016/02/redLedClock-300x224.png 300w" sizes="auto, (max-width: 633px) 100vw, 633px" /></a></p>
<p>Now, I want to turn off the Blue LED.  As the LED is active Low, to turn it off you write a 1 to the pin.  I do this as part of the setup of the pin by setting the initial drive state to high.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/02/blueLED.png"><img loading="lazy" decoding="async" class="alignnone size-large wp-image-542" src="https://iotexpert.com/wp-content/uploads/2016/02/blueLED.png" alt="blueLED" width="645" height="477" srcset="https://iotexpert.com/wp-content/uploads/2016/02/blueLED.png 645w, https://iotexpert.com/wp-content/uploads/2016/02/blueLED-600x444.png 600w, https://iotexpert.com/wp-content/uploads/2016/02/blueLED-300x222.png 300w" sizes="auto, (max-width: 645px) 100vw, 645px" /></a></p>
<p>The last step in the device configuration is to select the proper pins on the Design Wide Resources (DWR) pins tab.  Not setting the pins correctly is one of the most frequent errors that users make with PSoC Creator.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/01/creekFirmwarePins.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-531" src="https://iotexpert.com/wp-content/uploads/2016/01/creekFirmwarePins.png" alt="creekFirmwarePins" width="474" height="170" srcset="https://iotexpert.com/wp-content/uploads/2016/01/creekFirmwarePins.png 474w, https://iotexpert.com/wp-content/uploads/2016/01/creekFirmwarePins-300x108.png 300w" sizes="auto, (max-width: 474px) 100vw, 474px" /></a></p>
<p>The firmware for the project is simple.  In the first section (lines 3-8) I define a packed structure to serve as the I2C buffer.  The __attribute__((packed)) tells the compiler to put all of the members of the structure in contiguous bytes.  In the structure I defined below, if I had not marked it is packed, it is likely that the compiler would have put two bytes of padding after the pressureCounts and two bytes after the centiTemp.  It would have done this to work align those datatypes to make the memory access more efficient.</p>
<p>The next section (lines 17-23) I initialize the system and start the components.</p>
<p>The the main body of the program (lines 27-43) I ask the ADC if it is done reading the voltages,  if not go on, if so then calculate the different values and store them in the I2C buffer.  The &#8220;CyEnterCriticalSection&#8221; prevents an I2C interrupt from reading the buffer before the data is completely written to prevent a partial read of the data.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/01/CreekFirmwareMainC.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-530" src="https://iotexpert.com/wp-content/uploads/2016/01/CreekFirmwareMainC.png" alt="CreekFirmwareMainC" width="870" height="750" srcset="https://iotexpert.com/wp-content/uploads/2016/01/CreekFirmwareMainC.png 870w, https://iotexpert.com/wp-content/uploads/2016/01/CreekFirmwareMainC-600x517.png 600w, https://iotexpert.com/wp-content/uploads/2016/01/CreekFirmwareMainC-300x259.png 300w" sizes="auto, (max-width: 870px) 100vw, 870px" /></a></p>
<p>In the next post I will explain boot loading and the p4bootloader project.</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Index</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a class="row-title" href="https://iotexpert.com/2016/01/25/the-elkhorn-creek/" title="Edit “The Creek: IOT for the Elkhorn Creek”">The Creek: IOT for the Elkhorn Creek</a></td>
<td >Introduction</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/01/30/creek-architecture-1-0/" title="Edit “The Creek: Solution Architecture 1.0”">The Creek: Solution Architecture 1.0</a></td>
<td >Overall architecture</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/07/the-creek-board-1-1/" title="Edit “The Creek: Creek Board 1.1”">The Creek: Creek Board 1.1</a></td>
<td >Eagle layout of the board</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/14/creek-board-1-0-rcca/" title="Edit “The Creek: Creek Board 1.0 – RCCA”">The Creek: Creek Board 1.0 – RCCA</a></td>
<td >A discussion of the errors in the 1.0 board</td>
</tr>

<tr><td ><a class="row-title" href="https://iotexpert.com/2016/02/21/cypi/" title="Edit “The Creek: CYPI</td>
<td > a Raspberry Pi to Arduino Bridge”">The Creek: CYPI, a Raspberry Pi to Arduino Bridge</a></td>
<td > PSoC4 &lt;--&gt; Raspberry Pi Bridge Board</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/03/26/the-creek-psoc-4-creator-schematic-firmware/">The Creek: PSoC4 Creator Schematic and Firmware</a></td>
<td > Firmware to interface with the temperature and pressure sensors</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/10/the-creek-testing-the-firmware-2/">The Creek: Testing the Firmware</a></td>
<td > Using tools to verify that the PSoC 4 Firmware is working correctly</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/17/the-creek-testing-the-firmware/">The Creek: Testing the Bootloader</a></td>
<td > Make sure that you can load new firmware into the PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/04/24/the-creek-server-software-architecture/">The Creek: Software Architecture</a></td>
<td >All of the Raspberry Pi software connections</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/19/the-creek-install-mysql/">The Creek: Install MySql</a></td>
<td >Instruction to configure MySql</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/10/the-creek-install-tomcat/">The Creek: Install Tomcat</a></td>
<td >Instruction to configure Tomcat JSP Server</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/26/the-creek-collect-data-part-1/">The Creek: Data Collection Java (Part 1)</a></td>
<td >The Java program that reads the I2C and saves it in the database</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/03/the-creek-collect-data-part-2/">The Creek: Data Collection Java (Part 2)</a></td>
<td >The Java program that reads the I2C and saves it in the database</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/17/the-creek-create-the-chart-with-jfreechart/">The Creek: Create the Chart with JFreeChart</a></td>
<td >Using open source Java charting software to create plots of the Creek Depth</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/31/the-creek-flood-event-data-processor/">The Creek: Flood Event Data Processor</a></td>
<td >A batch program to create analyze the database and create a table of flood events</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/07/31/the-creek-flood-event-web-page/">The Creek: Flood Event Web Page</a></td>
<td > A batch program to create the flood event web page</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/07/the-creek-creek-server-1-1/">The Creek: Creek Server 1.1</a></td>
<td >Updates to all of the back off server programs to integrate charts</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/14/the-creek-web-pages-with-java-server-pages-jsp/">The Creek: JSP Web Page for www.elkhorn-creek.org</a></td>
<td >The JSP program to make the table and display the website</td>
</tr>

<tr><td >The Creek: Raspberry Pi Clock Stretching</td>
<td >Sorting out a bug in the system having to do with the Broadcomm Raspberry Pi Master not functioning well with clock stretching</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/08/28/the-creek-creek-server-1-2/">The Creek: Creek Server 1.2</a></td>
<td >Caching the web pages to make them faster</td>
</tr>
</tbody></table></div></p> </span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/the-creek-psoc-4-creator-schematic-firmware/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
