Skip to content

Fix for Issue 58 — Implementation of micros() #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 107 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
9e001c4
First commit of mspgcc
robertinant Mar 24, 2012
1447c8d
Intial checking of the MSP430Uploader class
robertinant Mar 24, 2012
19397d3
Initial support for the TI MSP430 16-bit MCU. Needs lots of testing and
robertinant Mar 24, 2012
6112352
Added OS X and Linux support
Mar 25, 2012
f887959
Mac OS X tools
robertinant Mar 27, 2012
92c84fd
Fixed type-o in tools unzip command
robertinant Mar 27, 2012
7254547
Rename cores/arduino to cores/msp430
robertinant Mar 27, 2012
6ffc9b5
Rename from Arduino to Energia
robertinant Mar 27, 2012
8438934
Rename arduino to erergia for the .exe
robertinant Mar 27, 2012
df0e3f9
Fix for bug #3: Timer based UART is broken and cleanup
robertinant Mar 31, 2012
b2f8300
Enhancement #4: Relocate TimerSerial
robertinant Mar 31, 2012
034a5a6
Enhancement #2
robertinant Mar 31, 2012
c9d7112
Remove msp430 specific code from main.cpp -> wiring.c
robertinant Mar 31, 2012
7d67f01
Enhancement #5
robertinant Mar 31, 2012
75019c9
Add delayMicroseconds()
robertinant Apr 2, 2012
c87e010
Icon, About and IDE GUI
Apr 3, 2012
7ff5257
Icon, About and IDE GUI
Apr 3, 2012
7dae8af
High quality icons 512x512 for OS X
Apr 3, 2012
c67ee32
Two examples: LEDs and PUSH button
Apr 3, 2012
630afba
Serial 9600bps Example
Apr 3, 2012
1d58fc1
Changed DCO freq. selection based on CALDCO_XXMHZ_ and F_CPU in board…
robertinant Apr 3, 2012
c1867e0
Fix missing _ in check for if def check
robertinant Apr 4, 2012
be72799
Fix hardcoded SMCLK
robertinant Apr 4, 2012
0d88ec1
For Mac OS X:
robertinant Apr 5, 2012
ad2eb10
For Windows:
robertinant Apr 5, 2012
b081d5d
And for Linux:
robertinant Apr 5, 2012
3407462
Improved Icon
Apr 5, 2012
cdcf16a
Fix type-o
robertinant Apr 6, 2012
e7e73b8
initial implementation of analogWrite
robertinant Apr 7, 2012
ca5bbe8
I2C Example with TMP102 Thermometer
Apr 7, 2012
5fcc847
Specific colour for error in console
Apr 8, 2012
ed527ca
I2C_Thermometer example with int
Apr 8, 2012
d1ded76
Updated About and more compact examples
Apr 11, 2012
f8a3d84
Fix type-o in in T2A2 define
robertinant Apr 11, 2012
ee80af0
Merge branch 'master' of github.com:energia/Energia
robertinant Apr 12, 2012
bfec9ee
Added P2.x to analogWrite
robertinant Apr 12, 2012
41c58be
Fix Tsample > 30us for internal temp sensor.
robertinant Apr 12, 2012
94dda60
Analog Input - MSP430 Internal Thermometer Example
Apr 12, 2012
82b5ffa
Changes to support linux. Fixed arg passing to mspdebug. Added
RickKimball Apr 13, 2012
cc88f9e
- Fixed msp430g22231 compilation
robertinant Apr 13, 2012
89d263b
Improved example
Apr 14, 2012
816f214
Add shiftIn and shiftOut
robertinant Apr 16, 2012
607be3f
Add defines for LSBFIRST and MSBFIRST
robertinant Apr 16, 2012
0daa803
Fix for Issue #9. Complete overhaul of external interrupts
robertinant Apr 16, 2012
a353bc3
Merge branch 'master' of github.com:energia/Energia
robertinant Apr 16, 2012
9aad28b
Fix for Issue #25: Change IconImage Arduino -> Energia
robertinant Apr 17, 2012
3fc0d72
Fix for Issue #10
robertinant Apr 18, 2012
4487980
Remove #pragma message
robertinant Apr 18, 2012
0e11fe4
Add INPUT_PULLUP flavor to pinMode(...)
robertinant Apr 18, 2012
b6d995a
Merge branch 'master' of github.com:energia/Energia
robertinant Apr 18, 2012
66e20d0
Fix for Issue #26. Windows energia.exe icon
robertinant Apr 19, 2012
37884e0
Add pulseIn(...)
robertinant Apr 19, 2012
1c64403
Fix for Issue #28
robertinant Apr 23, 2012
939c0dc
Add INPUT_PULLDOWN
robertinant Apr 23, 2012
2869bb9
Add INPUT_PULLDOWN flavor to pinMode(...)
robertinant Apr 23, 2012
70e1458
Pin names based on the silkscreen
Apr 25, 2012
418ecb2
Pin names based on the silkscreen and updated examples
Apr 25, 2012
f631a41
Update links
robertinant Apr 25, 2012
3f3b080
Clean slate
robertinant Apr 25, 2012
4aa0cbb
arduino->energia
robertinant Apr 25, 2012
d3aa770
This line is required by ant on Mac OS X.
Apr 25, 2012
99ba19c
Add version number to satisfy build dependency
robertinant Apr 25, 2012
b90fdd8
Merge branch 'master' of github.com:energia/Energia
robertinant Apr 25, 2012
046e786
Set version to 0006
robertinant Apr 25, 2012
3071b06
added example for 8x8 led display
Apr 25, 2012
14083d5
Merge branch 'master' of github.com:energia/Energia
Apr 25, 2012
3a84d38
added /opt/mspgcc/bin to the path for default mspgcc location
pbrier Apr 25, 2012
93e249e
Update ISR declaration: legacy -> modern
robertinant Apr 26, 2012
c241041
Update ISR declaration: legacy -> modern
robertinant Apr 26, 2012
cd8427e
Change Basics examples to be compatible with Launchpad.
robertinant Apr 28, 2012
b1d720d
Change Digital examples (sans tone ones) to be compatible with Launch…
robertinant Apr 28, 2012
2d487eb
Updated PushButton example with INPUT_PULLUP
Apr 29, 2012
0f20786
Added buzzer and analog MIC input
pbrier May 1, 2012
016f372
Added initial SPI support for USCI and USI peripherals.
RickKimball May 2, 2012
cb50037
Added initial SPI support for USCI and USI peripherals.
RickKimball May 2, 2012
4c37da6
Remove duplicate definitions. I moved these to pins_arduino.h.
RickKimball May 3, 2012
719d70c
implemented button, removed display glitch when tone is activated
May 4, 2012
a115324
defined missing timer pins for analog out
May 6, 2012
fc644a3
Added analog frequency and resolution
May 7, 2012
1a311af
- Chanved P1.4 timer from T0A2 to NOT_ON_TIMER
robertinant May 8, 2012
e08d96b
Merge branch 'master' of github.com:energia/Energia
robertinant May 8, 2012
bd3110d
Fix for Issue #47
robertinant May 15, 2012
eab57f3
Merge pull request #48 from energia/issue_47
robertinant May 16, 2012
fa0c5c0
- New version number format
robertinant May 20, 2012
2d87e0c
Change version check to accommodate new version number schema
robertinant May 20, 2012
a67810c
Conditionally hide "Upload Using Programmer" menu for msp430
robertinant May 20, 2012
9c4339d
New locations for 430-specific examples
May 21, 2012
21a3edb
Examples Updated with GREEN_LED, RED_LED and PUSH2
May 21, 2012
0522fa4
Conditionally show Tools->Burn Bootloader
robertinant May 21, 2012
906a76a
update gcc to version 4.6.3 20120301 (mspgcc LTS 20120406)
robertinant May 21, 2012
b7562f0
update gcc to version 4.6.3 20120301 (mspgcc LTS 20120406 patched to …
robertinant May 22, 2012
d99dd19
Merge branch 'master' of https://github.com/energia/Energia
robertinant May 22, 2012
f4ae1f3
Fix for Issue #32: Line numbers incorrect in the compiler messages
robertinant May 24, 2012
b891527
INPUT_PULLUP instead of INPUT
May 25, 2012
0f09a29
Fix for analogWrite() Issue #42. Freq only 245Hz vs 490 Hz needed / d…
robertinant May 25, 2012
cfe01eb
Merge pull request #32 from energia/issue_32
robertinant May 25, 2012
c5e7cd8
Change Arduino -> Energia in GUI text strings
robertinant May 26, 2012
7cbade3
Change domain arduino.cc -> energia.cc
robertinant May 26, 2012
b6d38b7
Nokia7110_430
May 26, 2012
2be486e
Nokia7110_430 — Temperature from built-in thermometer
May 26, 2012
27fe96a
add missing binary.h include
RickKimball May 26, 2012
d91d609
Nokia7110_430 — Stability enhancement
May 26, 2012
24f7bae
Add Launchapd Serial drivers
robertinant May 27, 2012
d6612f0
Merge branch 'master' of github.com:energia/Energia
robertinant May 27, 2012
27a2a9a
Nokia7110_430 Removed
May 27, 2012
897a17b
Example removed and scrapped
May 27, 2012
fdcba3e
Implementation of micros() — Fix for issue #58
May 31, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hardware/msp430/cores/msp430/Energia.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ int digitalRead(uint8_t);
uint16_t analogRead(uint8_t);
void analogWrite(uint8_t, int);
void analogReference(uint16_t);
void analogFrequency(uint32_t);
void analogResolution(uint16_t);



void delay(uint32_t milliseconds);

Expand Down
47 changes: 32 additions & 15 deletions hardware/msp430/cores/msp430/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "wiring_private.h"
#include "pins_energia.h"

uint16_t analog_reference = DEFAULT;
uint16_t analog_reference = DEFAULT, analog_period = F_CPU/490, analog_div = 0, analog_res=255; // devide clock with 0, 2, 4, 8

void analogReference(uint16_t mode)
{
Expand All @@ -46,9 +46,26 @@ void analogReference(uint16_t mode)
// - lower clock rated / input devider to conserve Energia.
// - pin configuration logic.

// Note set frequency before sending analog value
// Lowest fequency is defined by clock frequency F_CPU, and max counter value 2^16-1
// fmin = F_CPU / 2^16
void analogFrequency(uint32_t freq)
{
if ( freq <= F_CPU/(4*65334L) ) { analog_div = ID_3; freq *=8; }
else if ( freq <= F_CPU/(2*65334L) ) { analog_div = ID_2; freq *=4; }
else if ( freq <= F_CPU/(4*65334L) ) { analog_div = ID_1; freq *=2; }
analog_period = F_CPU/freq;
}

// Set the resulution (nr of counts for 100%), default = 255, large values may not work at all frequencies
void analogResolution(uint16_t res)
{
analog_res = res;
}

//Arduino specifies ~490 Hz for analog out PWM so we follow suit.
#define PWM_PERIOD F_CPU/490
#define PWM_DUTY PWM_PERIOD / 255
#define PWM_PERIOD analog_period // F_CPU/490
#define PWM_DUTY(x) ( (unsigned long)x*PWM_PERIOD / (unsigned long)analog_res )
void analogWrite(uint8_t pin, int val)
{
pinMode(pin, OUTPUT); // pin as output
Expand Down Expand Up @@ -86,45 +103,45 @@ void analogWrite(uint8_t pin, int val)
case T0A1: // Timer0 / CCR1
TA0CCR0 = PWM_PERIOD; // PWM Period
TA0CCTL1 = OUTMOD_7; // reset/set
TA0CCR1 = PWM_DUTY * val; // PWM duty cycle
TA0CTL = TASSEL_2 + MC_1; // SMCLK, up mode
TA0CCR1 = PWM_DUTY(val); // PWM duty cycle
TA0CTL = TASSEL_2 + MC_1 + MC_2 + analog_div; // SMCLK, up mode
break;
#if defined(__MSP430_HAS_TA3__)
case T0A2: // Timer0 / CCR1
TA0CCR0 = PWM_PERIOD; // PWM Period
TA0CCTL2 = OUTMOD_7; // reset/set
TA0CCR2 = PWM_DUTY * val; // PWM duty cycle
TA0CTL = TASSEL_2 + MC_1; // SMCLK, up mode
TA0CCR2 = PWM_DUTY(val); // PWM duty cycle
TA0CTL = TASSEL_2 + MC_1+ analog_div; // SMCLK, up mode
break;
#endif
#if defined(__MSP430_HAS_T1A3__)
//case: T1A0 // CCR0 used as period register
case T1A1: // Timer0 / CCR1
TA1CCR0 = PWM_PERIOD; // PWM Period
TA1CCTL1 = OUTMOD_7; // reset/set
TA1CCR1 = PWM_DUTY * val; // PWM duty cycle
TA1CTL = TASSEL_2 + MC_1; // SMCLK, up mode
TA1CCR1 = PWM_DUTY(val); // PWM duty cycle
TA1CTL = TASSEL_2 + MC_1+ analog_div; // SMCLK, up mode
break;
case T1A2: // Timer0 / CCR1
TA1CCR0 = PWM_PERIOD; // PWM Period
TA1CCTL2 = OUTMOD_7; // reset/set
TA1CCR2 = PWM_DUTY * val; // PWM duty cycle
TA1CTL = TASSEL_2 + MC_1; // SMCLK, up mode
TA1CCR2 = PWM_DUTY(val); // PWM duty cycle
TA1CTL = TASSEL_2 + MC_1+ analog_div; // SMCLK, up mode
break;
#endif
#if defined(__MSP430_HAS_T2A3__)
//case: T2A0 // CCR0 used as period register
case T2A1: // Timer0 / CCR1
TA2CCR0 = PWM_PERIOD; // PWM Period
TA2CCTL1 = OUTMOD_7; // reset/set
TA2CCR1 = PWM_DUTY * val; // PWM duty cycle
TA2CTL = TASSEL_2 + MC_1; // SMCLK, up mode
TA2CCR1 = PWM_DUTY(val); // PWM duty cycle
TA2CTL = TASSEL_2 + MC_1+ analog_div; // SMCLK, up mode
break;
case T2A2: // Timer0 / CCR1
TA2CCR0 = PWM_PERIOD; // PWM Period
TA2CCTL2 = OUTMOD_7; // reset/set
TA2CCR2 = PWM_DUTY * val; // PWM duty cycle
TA2CTL = TASSEL_2 + MC_1; // SMCLK, up mode
TA2CCR2 = PWM_DUTY(val); // PWM duty cycle
TA2CTL = TASSEL_2 + MC_1+ analog_div; // SMCLK, up mode
break;
#endif
case NOT_ON_TIMER: // not on a timer output pin
Expand Down