EmbeddedRelated.com
Forums
Memfault Beyond the Launch

LED Blink

Started by josef104 August 9, 2004

Jonathan Kirwan wrote:
> On Mon, 9 Aug 2004 17:24:05 +0100, Paul wrote:
> 
> 
>>You should all be programming in Modula-2.  M2 even has generics and OO
>>extensions now.
> 
> 
> What's wrong with M3, instead?

Prolog anyone?

I had a deep, but short fascination for this language in my distant 
past. I even wrote some apps in Turbo Prolog. Odd as it may seem. At 
that time I worked for a company whose core was mass flow controllers, 
but I ran systems division (LPCVD furnaces, PECVD etc). I designed an 
automated calibration station for the MFC's in prolog, as well as our 
client and stock tracking system. It was wierd, but worked. I have to 
confess I later re-wrote the client and stock systems in C.

Al


Beginning Microcontrollers with the MSP430

Hi Jon, 

> >You should all be programming in Modula-2.  M2
even has 
> generics and OO 
> >extensions now.
> 
> What's wrong with M3, instead?

Modula-3 wasn't designed by Wirth, but by DEC SRC and they were allowed
to use the Modula moniker, whereas DEC WRL was all Modula-2.  Modula-3
has some nice features, but is too big as a language, and isn't as
coherent as Modula-2.  Oberon is a nice language, but a bit too cut down
for my liking.

-- Paul.


On Mon, 9 Aug 2004 20:16:14 +0100, Paul wrote:

>> >You should all be programming in Modula-2.
 M2 even has 
>> generics and OO 
>> >extensions now.
>> 
>> What's wrong with M3, instead?
>
>Modula-3 wasn't designed by Wirth, but by DEC SRC and they were allowed
>to use the Modula moniker, whereas DEC WRL was all Modula-2.  Modula-3
>has some nice features, but is too big as a language, and isn't as
>coherent as Modula-2.  Oberon is a nice language, but a bit too cut down
>for my liking.

I never did get a working M3 compiler to play with.  Tried some distributions,
but got hung up getting them working and just didn't get the right amount
of
time at the right point in my life, I suppose.  Would have liked to try my hand
at it.

So... Since you like M2, what's keeping you from incorporating coroutines
into
C, again?  (Ever patient yet persistent, I am.)

Jon

Hi Jon, 

> I never did get a working M3 compiler to play
with.  Tried 
> some distributions, but got hung up getting them working and 
> just didn't get the right amount of time at the right point 
> in my life, I suppose.  Would have liked to try my hand at it.
> 
> So... Since you like M2, what's keeping you from 
> incorporating coroutines into C, again?  (Ever patient yet 
> persistent, I am.)

As much as I love coroutines, people nowadays have certain expectations
of an RTOS.  I really like coroutines, being able to write your own
scheduling policy such as message-based scheduling, round-robin
scheduling, priority-based scheduling, message queues, mailboxes, binary
and counting semaphores--all are possible with Modula-2's elegant
coroutine mechanism using SYSTEM.TRANSFER and SYSTEM.IOTRANSFER.
However, few people want to take the time to understand this elegant
concept, they just want pre-emption and timeslicing because that's on
their tick list, and a have-it-now, off-the-shelf, conformist solution
is a no brainer.

Why don't I put them into C?  Well, if I did, I can count the number of
customers who would use it without resorting to my fingers...

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors 

On Mon, 9 Aug 2004 23:36:48 +0100, you wrote:

>Hi Jon, 
>
>> I never did get a working M3 compiler to play with.  Tried 
>> some distributions, but got hung up getting them working and 
>> just didn't get the right amount of time at the right point 
>> in my life, I suppose.  Would have liked to try my hand at it.
>> 
>> So... Since you like M2, what's keeping you from 
>> incorporating coroutines into C, again?  (Ever patient yet 
>> persistent, I am.)
>
>As much as I love coroutines, people nowadays have certain expectations
>of an RTOS.  I really like coroutines, being able to write your own
>scheduling policy such as message-based scheduling, round-robin
>scheduling, priority-based scheduling, message queues, mailboxes, binary
>and counting semaphores--all are possible with Modula-2's elegant
>coroutine mechanism using SYSTEM.TRANSFER and SYSTEM.IOTRANSFER.
>However, few people want to take the time to understand this elegant
>concept, they just want pre-emption and timeslicing because that's on
>their tick list, and a have-it-now, off-the-shelf, conformist solution
>is a no brainer.
>
>Why don't I put them into C?  Well, if I did, I can count the number of
>customers who would use it without resorting to my fingers...

Ah, heck, Paul.  I'm just looking for the very simple mechanism I
documented
earlier.  Leave all that pre-emption scheduling crap on the way-side.  I'm
not
looking for pre-emption.  I'm not even looking for so much as two stacks. 
I'm
just looking for what amounts to a thunk.

Geez.  It's scaled down to the bare minimums, here.

Now do I get it?  ;)

Jon

Thanks for the help guys. Got a couple of more questions:
1) I learnt how to set a digital I/O pin to be set as output (for 
example: P6DIR |= 0x04).  How do you set it as an input?
2) Does anyone have any example programs in C for the MSP430F413STK2 
kit?  I am trying to learn to display stuff on the LCD on the board.
3) I searched for books to try to learn how to program the device, 
but really couldn't find anything (the only book on amazon looked 
like the user guide from TI and had bad reviews).  I have the 
MSP4304xx user guide and data sheets from TI, but they don't give 
much help on programming (like my question 1). I am also trying to 
read the guides that came with IAR EW.  Any tips/resources on how a 
beginner should approach learning to program this device?

Thanks,
Joseph


--- In msp430@msp4..., "cybermace5" <cybermace5@y...> wrote:
> > You're toggling P6.0 and P6.1 (the 0x03
is bits 0 and 1).  Try 
P6OUT ^> > 0x04.  You might want to use P6DIR |= 0x04 as well, to
set the 
port bit
> > as output.
> 
>                            Pins
>            | 7 | 6 | 5 | 4 |  | 3 | 2 | 1 | 0 |
>            |---------------|  |---------------|
>            | 8 + 4 + 2 + 1 |  | 8 + 4 + 2 + 1 |
> PxOUT = 0x         _                  _
> 
>             10:A, 11:B, 12:C, 13:D, 14:E, 15:F
> 
> 
> Until decimal-binary-hex becomes second nature, new coders should 
draw
> something like this to remember how to encode the
two digits. Simply
> look at the port pins you want to activate and add up the
> corresponding numbers below, converting to the appropriate letter if
> above 9. That can help avoid these frustrating little errors that 
are
> so easy to make.


Amazon has "Embedded Systems Design using the MSP430 series" for
sale. I 
bought it and is worth the 25 bucks or whatever it costs. It has a cd with 
code with it, and some examples, and would be helpful for someone starting 
out I think. It was for me. 

-Micah 


On Monday 09 August 2004 09:41 pm, josef104 wrote:
>  Thanks for the help guys. Got a couple of more questions:
>  1) I learnt how to set a digital I/O pin to be set as output (for
>  example: P6DIR |= 0x04). How do you set it as an input?
>  2) Does anyone have any example programs in C for the MSP430F413STK2
>  kit? I am trying to learn to display stuff on the LCD on the board.
>  3) I searched for books to try to learn how to program the device,
>  but really couldn't find anything (the only book on amazon looked
>  like the user guide from TI and had bad reviews). I have the
>  MSP4304xx user guide and data sheets from TI, but they don't give
>  much help on programming (like my question 1). I am also trying to
>  read the guides that came with IAR EW. Any tips/resources on how a
>  beginner should approach learning to program this device?
>
>  Thanks,
>  Joseph
>
>  --- In msp430@msp4..., "cybermace5" <cybermace5@y...>
wrote:
>  > > You're toggling P6.0 and P6.1 (the 0x03 is bits 0 and 1).
Try
>
>  P6OUT ^>
>  > > 0x04. You might want to use P6DIR |= 0x04 as well, to set the
>
>  port bit
>
>  > > as output.
>  >
>  > Pins
>  > | 7 | 6 | 5 | 4 | | 3 | 2 | 1 | 0 |
>  > |---------------| |---------------|
>  > | 8 + 4 + 2 + 1 | | 8 + 4 + 2 + 1 |
>  > PxOUT = 0x _ _
>  >
>  > 10:A, 11:B, 12:C, 13:D, 14:E, 15:F
>  >
>  >
>  > Until decimal-binary-hex becomes second nature, new coders should
>
>  draw
>
>  > something like this to remember how to encode the two digits. Simply
>  > look at the port pins you want to activate and add up the
>  > corresponding numbers below, converting to the appropriate letter if
>  > above 9. That can help avoid these frustrating little errors that
>
>  are
>
>  > so easy to make.
>
>  .
>
>
>
>
>
>
> 
>
>
>
>
>
>
>
>  .

josef104 wrote:
> Thanks for the help guys. Got a couple of more
questions:
> 1) I learnt how to set a digital I/O pin to be set as output (for 
> example: P6DIR |= 0x04).  How do you set it as an input?

If a pin is not an output then it is an input. At power up, by default, 
all pins are inputs.

> 2) Does anyone have any example programs in C for
the MSP430F413STK2 
> kit?  I am trying to learn to display stuff on the LCD on the board.

Have you looked on the ftp site for this group?

> 3) I searched for books to try to learn how to
program the device, 
> but really couldn't find anything (the only book on amazon looked 
> like the user guide from TI and had bad reviews).  I have the 
> MSP4304xx user guide and data sheets from TI, but they don't give 
> much help on programming (like my question 1). I am also trying to 
> read the guides that came with IAR EW.  Any tips/resources on how a 
> beginner should approach learning to program this device?

read the User Guide SLAU049. This is heavy going, but you'll need to 
start somewhere. I haven't read the book Micah mentions.

You are alwasy welcome to ask questions here.

Al


Hi, 

> 1) I learnt how to set a digital I/O pin to be set
as output (for
> example: P6DIR |= 0x04).  How do you set it as an input?
> 
> Set 0 for those bits desired as input. If you want all input, 
> it is P6DIR |= 0x00

Actually not.  P6DIR = 0 or P6DIR &= 0, but certainly not P6DIR |= 0.

-- Paul.


1) I learnt how to set a digital I/O pin to be set as output (for 
example: P6DIR |= 0x04).  How do you set it as an input?

Set 0 for those bits desired as input. If you want all input, it is P6DIR |=
0x00

2) Does anyone have any example programs in C for the MSP430F413STK2 
kit? 

Unfortunately not. The Olimex.com website will have a few programs in assembly
but that's about it. Sadly, these files don't even have proper
documentation with them. To run the kit in C, you will need to convert these
assembly programs in C. It will not be easy for a beginner. I bought the
MSP430F449STK2 because it came with an LCD module on the kit. It took me the
MSP430F449 User Guide (read on LCD:4-Mux), Olimex's LCD Datasheet (which is
really dumb) and Olimex's MSP430F449STK2 pin connections before it made any
sense. Took me about a week to figure it all out, longer than I expected. I
wrote a couple of functions to do a number of cool tricks for the LCD, display
numbers, text, scrolling text and sentences and so on. But that was about it.
Your kit (MSP430F413STK2) uses a different LCD, so the pin connections may be
different. Also, activating the segments on the LCD will be different. But if
you want to have a look at the software I wrote for the LCD anyway, let me know.
The other stuff like serial communcation, ADC etc etc are covered in adequate
detail in TI demo C files. I conquered the LCD first because I can use it in
debugging all my projects, which is really useful.

3) I searched for books to try to learn how to program the device, 
but really couldn't find anything (the only book on amazon looked 
like the user guide from TI and had bad reviews).  I have the 
MSP4304xx user guide and data sheets from TI, but they don't give 
much help on programming (like my question 1). I am also trying to 
read the guides that came with IAR EW.  Any tips/resources on how a 
beginner should approach learning to program this device?

In fact, I bought the TI book that everyone is talking about from Amazon.com but
I found it a poor source for ideas or reference (it will leave you more
confused). Stick with the TI documentation (User Guide) for your chip, and
master to use IAR software. Printed copy of these documents will be helpful than
swapping windows. You won't find specific software in C for your kit, but
you will find C code for your chip from TI Website. Take one step at a time,
like input/output/LED which is a good start. Next you would want to take care of
interrupts, timing and so on. You can also ask this group if you are stuck on
anything.

IL


----- Original Message ----- 
  From: josef104 
  To: msp430@msp4... 
  Sent: Monday, August 09, 2004 10:41 PM
  Subject: [msp430] Re: LED Blink


  Thanks for the help guys. Got a couple of more questions:
  1) I learnt how to set a digital I/O pin to be set as output (for 
  example: P6DIR |= 0x04).  How do you set it as an input?
  2) Does anyone have any example programs in C for the MSP430F413STK2 
  kit?  I am trying to learn to display stuff on the LCD on the board.
  3) I searched for books to try to learn how to program the device, 
  but really couldn't find anything (the only book on amazon looked 
  like the user guide from TI and had bad reviews).  I have the 
  MSP4304xx user guide and data sheets from TI, but they don't give 
  much help on programming (like my question 1). I am also trying to 
  read the guides that came with IAR EW.  Any tips/resources on how a 
  beginner should approach learning to program this device?

  Thanks,
  Joseph


  --- In msp430@msp4..., "cybermace5" <cybermace5@y...> wrote:
  > > You're toggling P6.0 and P6.1 (the 0x03 is bits 0 and 1).  Try 
  P6OUT ^  > > 0x04.  You might want to use P6DIR |= 0x04 as well, to set
the 
  port bit
  > > as output.
  > 
  >                            Pins
  >            | 7 | 6 | 5 | 4 |  | 3 | 2 | 1 | 0 |
  >            |---------------|  |---------------|
  >            | 8 + 4 + 2 + 1 |  | 8 + 4 + 2 + 1 |
  > PxOUT = 0x         _                  _
  > 
  >             10:A, 11:B, 12:C, 13:D, 14:E, 15:F
  > 
  > 
  > Until decimal-binary-hex becomes second nature, new coders should 
  draw
  > something like this to remember how to encode the two digits. Simply
  > look at the port pins you want to activate and add up the
  > corresponding numbers below, converting to the appropriate letter if
  > above 9. That can help avoid these frustrating little errors that 
  are
  > so easy to make.



  .




        
             
       
       


------
  . 







Memfault Beyond the Launch