<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: SPI -9bit</title>
		<link>http://forums.leaflabs.com/topic.php?id=243</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:19:54 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=243" rel="self" type="application/rss+xml" />

		<item>
			<title>poslathian on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-2550</link>
			<pubDate>Mon, 15 Nov 2010 15:26:04 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">2550@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hmm, nope the TC flag belongs wholly to the usart port, which libmaple nor the bootloader should be touching at startup. Is there a code dump somewhere? Perhaps you are querying the TC flag before sending any data. According to the datasheet, the reset value of the usart status register is 0xxxxx00C0  where the x's are reserved and you shouldnt care about them. &#60;/p&#62;
&#60;p&#62;However, the &#34;C0&#34; is 11000000, and that second 1 happens to be the TC bit. Long story short, TC *should* be high on reset.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wilsonjc on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-2516</link>
			<pubDate>Sun, 14 Nov 2010 15:37:40 +0000</pubDate>
			<dc:creator>wilsonjc</dc:creator>
			<guid isPermaLink="false">2516@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Is there some reason why checking the TC flag, to see if the last byte has been sent by the USART, would cause other problems.   for example does the usb port routines use the TC flag,  since reading the TC flag clears it as well.  we seem to have a problem at reset where maple will go into limbo and it take three resets to get it going again.    Could be my code, since I don't do a lot of C programming,  but I just wanted to be sure.   thanks
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-2413</link>
			<pubDate>Thu, 11 Nov 2010 00:32:23 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">2413@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;awesome! looking good.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wilsonjc on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-2380</link>
			<pubDate>Wed, 10 Nov 2010 11:37:13 +0000</pubDate>
			<dc:creator>wilsonjc</dc:creator>
			<guid isPermaLink="false">2380@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Finally got the display working. &#60;a href=&#34;http://www.flickr.com/photos/55765056@N06/5164571962/&#34; rel=&#34;nofollow&#34;&#62;http://www.flickr.com/photos/55765056@N06/5164571962/&#60;/a&#62;&#60;br /&#62;
We are still having problems with detecting if the last data bit has been transmitted.    I have been waiting for the TC flag to go high but that has made the whole system a little unreliable on reset.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-2248</link>
			<pubDate>Sun, 07 Nov 2010 18:10:33 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">2248@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;There should be some low level registers that indicate when transmission is busy/completed, and these can be configured to fire interrupts if you want them to. This is probably best configured with the DMA (so you can toggle CS around mutli-byte transmissions), which will have library support soon. But the temporary hack solution is to just poll the status registers. I should point out that the USART's can be configured to automatically control the CS lines, with some more hacking - since the frontend for that is not provided by the library. &#60;/p&#62;
&#60;p&#62;the register you want is the &#34;SR&#34; register of the given USART port you are using (1, 2, or 3). The TC bit (bit 6) of the SR register indicates whether or not the transfer is complete (which you can use to determine when to manually toggle any CS line). &#60;/p&#62;
&#60;p&#62;The standard USART regmap can be typedefed like this:&#60;/p&#62;
&#60;p&#62;/* peripheral register struct  */&#60;br /&#62;
typedef struct usart_port {&#60;br /&#62;
    volatile uint32 SR;       // Status register&#60;br /&#62;
    volatile uint32 DR;       // Data register&#60;br /&#62;
    volatile uint32 BRR;      // Baud rate register&#60;br /&#62;
    volatile uint32 CR1;      // Control register 1&#60;br /&#62;
    volatile uint32 CR2;      // Control register 2&#60;br /&#62;
    volatile uint32 CR3;      // Control register 3&#60;br /&#62;
    volatile uint32 GTPR;     // Guard time and prescaler register&#60;br /&#62;
} usart_port;&#60;/p&#62;
&#60;p&#62;and youll want to setup the object like this:&#60;/p&#62;
&#60;p&#62;usart_port *myPort = (usart_port*)(ADDR);&#60;/p&#62;
&#60;p&#62;where ADDR is one of:&#60;br /&#62;
#define USART1_BASE    0x40013800&#60;br /&#62;
#define USART2_BASE    0x40004400&#60;br /&#62;
#define USART3_BASE    0x40004800&#60;br /&#62;
#define UART4_BASE     0x40004C00  // High-density devices only (Maple Native)&#60;br /&#62;
#define UART5_BASE     0x40005000  // High-density devices only (Maple Native)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wilsonjc on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-2236</link>
			<pubDate>Sun, 07 Nov 2010 14:29:02 +0000</pubDate>
			<dc:creator>wilsonjc</dc:creator>
			<guid isPermaLink="false">2236@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks for the help.    I thought setting the clock pin as an output using pinMode would be enough but as it turns out I needed to use GPIO_MODE_AF_OUTPUT.    I was able to get the the lcd display working but I still have a problem with the chip select (CS) going high when the usart is still sending data.   Is there any way to be sure that all the data has been sent from the usart port before I set the CS high?     I am using a delay right now but that will slow things down too much.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-2070</link>
			<pubDate>Wed, 27 Oct 2010 15:12:06 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">2070@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;did you appropriately configure the sck pin into AF_OUTPUT?&#60;/p&#62;
&#60;p&#62;when you configure a peripheral to use external pins (like spi or i2c or usart) the pins need to be enabled in the GPIO control regs, as well as enabling the peripheral register, as well as enabling the clock control (rcc) register corresponding to the used GPIO bank and the peripheral itself. It sounds a bit much, but we do this for you in most cases. &#60;/p&#62;
&#60;p&#62;For example, to use Serial1.begin(), the wirish library is setting up the tx and rx pins first and then calling usart_init which calls the rcc (clock config) init, and then finally enables the usart peripheral itself. &#60;/p&#62;
&#60;p&#62;in HardwareSerial.cpp:&#60;br /&#62;
 in function HardwareSerial::begin&#60;/p&#62;
&#60;p&#62;on line 75, see how gpio_set_mode is called to init the pins? add to that a call to setup your sclk pin, set it to GPIO_MODE_AF_OUTPUT  and you should be all set!&#60;/p&#62;
&#60;p&#62;we will have to think of the right way to integrate this into the library, since by default the sclk pin isnt used.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wilsonjc on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-2068</link>
			<pubDate>Wed, 27 Oct 2010 14:49:32 +0000</pubDate>
			<dc:creator>wilsonjc</dc:creator>
			<guid isPermaLink="false">2068@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I am trying to use the usart in the synchronous mode with 9 bits but I can't seem to get the external clock signal to work.   Here is some of the code I added to usart.c&#60;br /&#62;
I set the M bit to get a 9bit frame, and CLKEN to get the external clock signal.   any idea why I get just data but don't get the external clock?  &#60;/p&#62;
&#60;p&#62;    port-&#38;gt;CR1 = USART_TE          &#124;    // transmitter enable&#60;br /&#62;
		USART_M           &#124;    // 9 bit data enable (I added this)&#60;br /&#62;
                USART_RE          &#124;    // receiver enable&#60;br /&#62;
                USART_RXNEIE;          // receive interrupt enable&#60;/p&#62;
&#60;p&#62;    port-&#38;gt;CR2 &#124;= USART_CLKEN;           // enable the SCK clock pin (I added this)&#60;/p&#62;
&#60;p&#62;    /* Enable the USART and set mode to 9 synchronous mode */&#60;br /&#62;
    port-&#38;gt;CR1 &#124;= USART_UE;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wilsonjc on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-1912</link>
			<pubDate>Thu, 21 Oct 2010 19:18:10 +0000</pubDate>
			<dc:creator>wilsonjc</dc:creator>
			<guid isPermaLink="false">1912@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;thanks,   I am trying to interface to the Nokia 6100 Display, but the 9 bit interface without using bit banging seems to be a little difficult.     It seems like the only way is to change the library.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-1899</link>
			<pubDate>Thu, 21 Oct 2010 16:58:09 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1899@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I believe i2c can be configured with a 9 bit frame (were working on adding a hw interface to i2c). does your device support i2c? If not, there still might be a way to hack something together. I have actually seen a few reference implementations of driving various nokia lcd's via stm32, Ill take a look.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wilsonjc on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-1851</link>
			<pubDate>Tue, 19 Oct 2010 19:46:25 +0000</pubDate>
			<dc:creator>wilsonjc</dc:creator>
			<guid isPermaLink="false">1851@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;It seems that getting the USART port to send 9 bit serial data isn't as easy as I thought it would be.    I thought I would alter the serial/usart setup routines in lib but I'm not sure that this would be a good idea since i would have to do work every time a new version of the maple IDE was released.    Is there any plans to add more options to the SerialN.begin(baudrate) command?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wilsonjc on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-1775</link>
			<pubDate>Tue, 12 Oct 2010 19:12:50 +0000</pubDate>
			<dc:creator>wilsonjc</dc:creator>
			<guid isPermaLink="false">1775@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Wow, Yes, this is exactly what I need to do.   I am trying to interface to the Nokia 6100/6610 display.   It has a 9-bit frame and I wanted to use the built in interfaces to control it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>perry on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-1774</link>
			<pubDate>Tue, 12 Oct 2010 17:31:54 +0000</pubDate>
			<dc:creator>perry</dc:creator>
			<guid isPermaLink="false">1774@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;hi wilson,&#60;/p&#62;
&#60;p&#62;The hardware spi peripheral on the stm32 doesn't support 9-bit spi, only 8-bit and 16-bit data frames. It appears that you can use the USART to generate 9-bit frames, take a look at this post:&#60;br /&#62;
&#60;a href=&#34;http://www.micromouseonline.com/forum/viewtopic.php?f=7&#38;amp;p=2756&#34; rel=&#34;nofollow&#34;&#62;http://www.micromouseonline.com/forum/viewtopic.php?f=7&#38;amp;p=2756&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-1773</link>
			<pubDate>Tue, 12 Oct 2010 14:25:38 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">1773@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;What device are you trying to interface to? Sounds like you'll have to change to a software implementation of a 9 bit SPI bus.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wilsonjc on "SPI -9bit"</title>
			<link>http://forums.leaflabs.com/topic.php?id=243#post-1772</link>
			<pubDate>Tue, 12 Oct 2010 14:13:16 +0000</pubDate>
			<dc:creator>wilsonjc</dc:creator>
			<guid isPermaLink="false">1772@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I have to send 9 bits and only 9 bits to a device on the SPI interface.   It seems that the SPI interface will only send 8 or 16 bits,  but is there a way to send just one bit?    I tried to bit bang the 9th bit but I don't know of any way of turning off the hardware SPI interface. :(&#60;/p&#62;
&#60;p&#62;Any help would be appreciated.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
