Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for issue #300 #305

Merged
merged 2 commits into from

2 participants

Brian Schmalz Ricklon
Brian Schmalz
Owner

Here's the second pull request for the other changes. I know it includes both commits, but I can't figure out how to create a branch that backs out the one change and only has the newer change.

Brian Schmalz EmbeddedMan Fix for issue #300 - adds code to detect 'high' baud rates (>=200000 …
…baud) and uses BRGH = 1 (the high baud rate divisor) to get them right.

Tested with all standard baud rates from 9600 to 921600 using terminal emulator. Tested at 2,000,000 (2Mbps) using scope. All correct.
2573386
Ricklon
Owner

I merged the 298 chance. It's now giving and issue for this pull. I'll have to see what the conflict is.

Ricklon
Owner

Brian,

Any chance you can do a pull request for this again? A previous pull request merge conflicted with it.

--Rick

Brian Schmalz
Owner

Sure, but it may take me a bit to get it all set up again - I'm on travel until the 3rd.

Brian Schmalz EmbeddedMan Merge branch 'master' of https://github.com/chipKIT32/chipKIT32-MAX
Conflicts:
	hardware/pic32/cores/pic32/HardwareSerial.cpp
Included in this change is the fix for issue #300 - adding ability to use high baud rates for hardware serial ports.
3d03435
Brian Schmalz
Owner

Rick, I've updated the code on my chipKIT repo, but it won't let me issue another pull request because there already is one outstanding. However, if you do a pull now, it should merge cleanly. Let me know if it doesn't.

Ricklon ricklon merged commit 7a65551 into from
Ricklon
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 23, 2012
  1. Brian Schmalz

    Fix for issue #300 - adds code to detect 'high' baud rates (>=200000 …

    EmbeddedMan authored
    …baud) and uses BRGH = 1 (the high baud rate divisor) to get them right.
    
    Tested with all standard baud rates from 9600 to 921600 using terminal emulator. Tested at 2,000,000 (2Mbps) using scope. All correct.
Commits on Dec 29, 2012
  1. Brian Schmalz

    Merge branch 'master' of https://github.com/chipKIT32/chipKIT32-MAX

    EmbeddedMan authored
    Conflicts:
    	hardware/pic32/cores/pic32/HardwareSerial.cpp
    Included in this change is the fix for issue #300 - adding ability to use high baud rates for hardware serial ports.
This page is out of date. Refresh to see the latest.
1  .gitignore
View
@@ -6,4 +6,3 @@
*.out
*.class
*.svn
-./build/upload.properties
BIN  build/antlibs/aws-ant-tasks-0.4-SNAPSHOT.jar
View
Binary file not shown
BIN  build/antlibs/aws-java-sdk-1.3.8.jar
View
Binary file not shown
BIN  build/antlibs/commons-codec-1.6.jar
View
Binary file not shown
BIN  build/antlibs/commons-logging-1.1.1.jar
View
Binary file not shown
BIN  build/antlibs/httpclient-4.1.1.jar
View
Binary file not shown
BIN  build/antlibs/httpcore-4.1.jar
View
Binary file not shown
BIN  build/antlibs/jackson-core-asl-1.9.11.jar
View
Binary file not shown
BIN  build/antlibs/jackson-mapper-asl-1.9.11.jar
View
Binary file not shown
41 build/build.xml
View
@@ -4,15 +4,13 @@
<!--echo message="os.arch = ${os.arch}" /-->
<!--echo message="os.version = ${os.version}" /-->
<!-- Sets properties for macosx/windows/linux depending on current system -->
- <property file="upload.properties"/>
- <property name="aws.bucket" value="chipkit" />
<condition property="macosx"><os family="mac" /></condition>
<condition property="windows"><os family="windows" /></condition>
<condition property="linux"><os family="unix" /></condition>
<condition property="linux64"><os family="unix" arch="amd64" /></condition>
-<condition property="platform"
+ <condition property="platform"
value="macosx"><os family="mac" /></condition>
<condition property="platform"
value="windows"><os family="windows" /></condition>
@@ -321,11 +319,7 @@
macosx/mpide-${version}.dmg
=======================================================
- </echo>
- <propertyfile file="upload.properties">
- <entry key="version" value="${version}"/>
- </propertyfile>
-
+ </echo>
</target>
@@ -654,37 +648,6 @@
</copy>
</target>
-->
- <!-- Task for setting up the aws-ant-tasks -->
- <target name="awstasks.setup">
- <path id="tasks.path">
- <fileset dir="antlibs" includes="*.jar"/>
- </path>
-
- <taskdef name="s3put" classpath="antlibs" classname="it.corley.ant.S3PutTask"
- classpathref="tasks.path"/>
- <typedef name="contenttype.mapping" classname="it.corley.ant.ContentTypeMapping" classpathref="tasks.path"/>
- <typedef name="cachecontrol.mapping" classname="it.corley.ant.CacheControlMapping" classpathref="tasks.path"/>
- <typedef name="contentencoding.mapping" classname="it.corley.ant.ContentEncodingMapping" classpathref="tasks.path"/>
- </target>
- <!-- Upload the current build -->
- <target name="upload" description="Use the Task" depends="awstasks.setup">
- <property file="test.properties"/>
- <s3put key="${aws.access_key}" secret="${aws.secret_key}" bucket="${aws.bucket}"
- dest="builds" publicread="true" cacheControl="3600" contentType="application/x-readme">
- <fileset dir="macosx" includes="mpide-${version}.dmg"/>
- <contenttypemapping extension="md" contenttype="text/plain"/>
- <cachecontrolmapping extension="md" maxage="7200"/>
- <contentencodingmapping extension="md" encoding="UTF-8" />
- </s3put>
-
- </target>
- <!-- Debugging echo target for s3, other values could be added as needed. -->
- <target name="echo">
- <echo message="${aws.access_key}"/>
- <echo message="${aws.secret_key}"/>
- <echo message="${aws.bucket}"/>
- <echo message="${version}"/>
- </target>
</project>
24 hardware/pic32/cores/pic32/HardwareSerial.cpp
View
@@ -59,6 +59,7 @@
//* Nov 12, 2012 <GeneApperson> Rewrite for board variant support
//* Sep 8, 2012 <BrianSchmalz> Fix dropping bytes on USB RX bug
//* Jul 26, 2012 <GeneApperson> Added PPS support for PIC32MX1xx/MX2xx devices
+//* Nov 23, 2012 <BrianSchmalz> Auto-detect when to use BRGH = 1 (high baud rates)
//************************************************************************
#ifndef __LANGUAGE_C__
#define __LANGUAGE_C__
@@ -87,7 +88,8 @@
/* ------------------------------------------------------------ */
/* General Declarations */
/* ------------------------------------------------------------ */
-
+// Baud rate above which we use high baud divisor (BRGH = 1)
+#define LOW_HIGH_BAUD_SPLIT 200000
/* ------------------------------------------------------------ */
/* HardwareSerial Object Class Implementation */
@@ -215,13 +217,21 @@ void HardwareSerial::begin(unsigned long baudRate)
iec->set = bit_rx; //enable rx interrupts
/* Initialize the UART itself.
- */
- // http://www.chipkit.org/forum/viewtopic.php?f=7&t=213&p=948#p948
- uart->uxBrg.reg = ((__PIC32_pbClk / 16 / baudRate) - 1); // calculate actual BAUD generate value.
+ ** http://www.chipkit.org/forum/viewtopic.php?f=7&t=213&p=948#p948
+ ** Use high baud rate divisor for bauds over LOW_HIGH_BAUD_SPLIT
+ */
uart->uxSta.reg = 0;
- uart->uxMode.reg = (1 << _UARTMODE_ON); //enable UART module
- uart->uxSta.reg = (1 << _UARTSTA_UTXEN) + (1 << _UARTSTA_URXEN); //enable transmitter and receiver
-
+ if (baudRate < LOW_HIGH_BAUD_SPLIT)
+ {
+ uart->uxBrg.reg = ((__PIC32_pbClk / 16 / baudRate) - 1); // calculate actual BAUD generate value.
+ uart->uxMode.reg = (1 << _UARTMODE_ON); // enable UART module
+ }
+ else
+ {
+ uart->uxBrg.reg = ((__PIC32_pbClk / 4 / baudRate) - 1); // calculate actual BAUD generate value.
+ uart->uxMode.reg = (1 << _UARTMODE_ON) | (1 << _UARTMODE_BRGH); // enable UART module
+ }
+ uart->uxSta.reg = (1 << _UARTSTA_UTXEN) + (1 << _UARTSTA_URXEN); // enable transmitter and receiver
}
/* ------------------------------------------------------------ */
1  hardware/pic32/cores/pic32/p32_defs.h
View
@@ -108,6 +108,7 @@ typedef struct {
/* UxMODE - Define bits in UART mode port
*/
#define _UARTMODE_ON 15
+#define _UARTMODE_BRGH 3
/* UxSTA - Define bits in UART status/control register
*/
Something went wrong with that request. Please try again.