admirlk

My Stupid Question Space

12 posts in this topic

Since I am liable to have a lot of these, I figure it is best to just consolidate them all into one thread.

I think I am fairly competent in C++, for desktop, but am new to embedded. My electronic knowledge is very basic, at best. Most of my questions will most likely concern the architectural, or electronic, elements of the msp430g2553 in general, since that is what I am working with, although they could be more general, or involve code, as I learn more.

I am currently reading MSP430 Microcontroller Basics . If you are familiar with the book , you will know it involves a different chip and was probably written before the Launchpad came out(?). I am definitely not using the same board anyway. Instead of trying to use the on-board stuff, I am working with a breadboard, also. Everything else aside, this means that is not possible for me to just copy the code and see how it works. This brings me to stupid question #1.

The second program involved using a button to turn the LED on/off. I figured out how to enable the internal pull up/pull down resistor, but did not find anything about how to set it to one or the other. Since what I did worked, is it safe to assume that the chip is smart enough to figure out witch one you want? 

Share this post


Link to post
Share on other sites

Section 8.2.4 of the User's Guide says:

Quote

Each bit in each PxREN register enables or disables the pullup/pulldown resistor of the corresponding I/O pin. The corresponding bit in the PxOUT register selects if the pin is pulled up or pulled down.

 

Share this post


Link to post
Share on other sites

Ahh, I kept missing that second part, and it makes sense. It is good to know that I just got lucky on my first try. Now I will not be scratching my head, next time when I would probably not be so lucky. Much thanks!

Share this post


Link to post
Share on other sites

FWIW, I still find myself referring back to sections in MSP430 Microcontroller Basics.

One of the benefits I find working with the MSP430 line is the general code compatibility across many of the devices.  I also make extensive use of the code examples available in the MSP430Ware toolset. Often those examples provide a reasonable starting point when working with the different peripherals or devices.

One of the real benefits with the '430 line is power management. With that in mind, take a look at the code examples using the interrupt (ISR) models rather than polling. An example of such would be msp430g2xx3_P1_02.c Which would be useful for a pushbutton activated LED.  FWIW, you'll find good code analogs for the Davies book examples in the MSP430Ware peripheral examples.

Have fun,

Bob

Share this post


Link to post
Share on other sites

May I recommend that you consider buying a cheap (sub $10), 8-bit, low speed (eg 24 MHz), logic analyser sooner than later ?

That, plus experience with the MSP430 'register page' of the CCS IDE 'Debugger' will be good friends to help you sort out the programming of MSP430 family peripherals.

Welcome to the forum!

Share this post


Link to post
Share on other sites

Hi,

I have not gotten to interrupts yet, just just the cheap and dirty way the book describes. I need to wrap my head around bitwise operations first. I also need to get used to CSS. I never looked at registers before, except for the little assembly programing I have done, so I did not think to do so originally. I did find them, and found out why I got lucky, all the pins were set at the start. That leads me to another question: is there a way to switch to binary from hex? It would save me having to look at a chart to see what actually changes.

veryalive, I have an analog scope, I think that would work as a limited logic analyzer? At this point I have only turned an LED on/off with a button, so there is not much to see with either one. :laugh:

Share this post


Link to post
Share on other sites
1 hour ago, admirlk said:

That leads me to another question: is there a way to switch to binary from hex? It would save me having to look at a chart to see what actually changes.

 

I have at times used the calculator that comes with windows to do quick hex -> binary as well as binary -> hex.  From the view menu of the calculator, choose "Programmer".

Once you have moved past the blinking LED and dive further into the wonderful world of microcontrollers, you will appreciate having a logic analyzer with 8-16 channels.  They are worth their weight in gold when troubleshooting communication problems.

 

Share this post


Link to post
Share on other sites

I was hoping there was a setting, or something, I did not find. If I remember right, it was easy to switch back and forth in VS.  I have a PDF that goes up to 0xff, on one page, so that is handier than using a calculator. I could probably whip up a converter to do the same easy enough also. I did that for converting to/from metric because I got tired of looking it up all the time.

I hope to get past the LEDs eventually, but there is a lot more for me to learn, and I cannot just breeze through it all, like with Arduino. And before someone says look into Energia, I am not looking for the easy way out. I am hoping to eventually find employment.

Share this post


Link to post
Share on other sites
Quote

I was hoping there was a setting, or something, I did not find.

If you are referring to a setting in CCS then it can be done like this:

1) Select the register tab and then the register you are interested in while in debug mode

2) Right click on the number of interest int the value column and then number format

3) Select Binary

I agree with the others.  If you are serious, then get a logic analyzer even if it is a cheap 24 MHz one off of eBay.  Also, take advantage of the TI training videos, e.g. http://processors.wiki.ti.com/index.php/Getting_Started_with_the_MSP430_LaunchPad_Workshop?keyMatch=msp430 training&tisearch=Search-EN-Everything

http://processors.wiki.ti.com/index.php/Getting_Started_with_the_MSP430G2553_Value-Line_LaunchPad_Workshop

http://processors.wiki.ti.com/index.php/Category:CCS_Training?keyMatch=code composer studio training&tisearch=Search-EN-Everything

Share this post


Link to post
Share on other sites

That is exactly what I was looking for. Switching all at once would be better, but cannot have everything.

I started with the value line workshop, but did not care for all the C&P involved. The book seems to give better detail on why you are doing something, as you are doing it. Plus it allows me to work on a breadboard, and figure out how I need to write the code to make it work, as my first question shows. Unfortunately I have not had time to move onto the next step; adding a second LED and button.

I have taken a little time to look into logic analyzers, and found this one on ebay, that should work with sigrok. I assume that is what you all are referring to.

Share this post


Link to post
Share on other sites

Yes, that's the logic analyser.   Good price, too.   I have 4 of these units attached to various projects / breadboards.    And using two laptops the odd time.

Cheers.

Share this post


Link to post
Share on other sites

Cool, it is certainly cheap enough, that I will probably go ahead and order one. Not sure when I will get to use it, but it never hurts to have test gear.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now