Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Simulation for programs in msp430.

Status
Not open for further replies.

iVenky

Advanced Member level 2
Joined
Jul 11, 2011
Messages
584
Helped
37
Reputation
76
Reaction score
35
Trophy points
1,318
Location
College Station, Texas
Activity points
6,124
We want to simulate c programs that we wish to burn in msp430. How can we do that?

Thanks in advance.
 

Someone please answer. We don't have msp430 yet. Till then we want to simulate our programs. How can we simulate? Is it possible to simulate in Code composer?


Thanks
 


Are you sure that IAR Embedded Workbench Kickstart has a simulator?

Thanks in advance.
 

Hello!

I use IAR, but I don't understand what can be done with a simulator.
If you use ONLY the chip, that's fine, but if you try to program a chip that connects
to an external device, then you simply get no reply. If you try to simulate the communication
with a SPI device, for instance, you get stuck at every read byte since the flag never comes.
Simulting a program that runs only internally without I/O seems of limited interest to me...
Well, that said, I have never tried to fully understand it, so there are probably many issues
I am missing...

Dora.
 

Some things can be done with the simulator but interaction with an external device is not one of them.
You can check external interrupts , you can check correct timer operation , you can usually set ADC values to check if the code reacts correctly , measure the execution time etc.

A hardware simulation is obviously better if possible.

Alex
 

I have msp430 low power mode. It's like a pen drive. But I don't know how to work with it. I would be much obliged if you could help me.

Thanks in advance
 

As I said I don't have much experience with MSP430, I only bought a couple of launchpads with the value line mcu and run some ready project through the debugger on the launchpad and the IAR simulator.
You need someone who knows how to work with these mcu and I don't have much knowledge.
 

Hello!

I use IAR, but I don't understand what can be done with a simulator.
If you use ONLY the chip, that's fine, but if you try to program a chip that connects
to an external device, then you simply get no reply. If you try to simulate the communication
with a SPI device, for instance, you get stuck at every read byte since the flag never comes.
Simulting a program that runs only internally without I/O seems of limited interest to me...
Well, that said, I have never tried to fully understand it, so there are probably many issues
I am missing...

Dora.

We want to interface GPS with MSP 430. We don't have any experience with msp 430. We have done programs using atmega before but we don't know how to work with msp 430. Could you please guide us?.

Thanks in advance.
 

Hello!

GPS can be interfaced quite easily with MSP430 (and I guess any other processor).
There is an example here. Quite old...
**broken link removed**
But I don't know how to simulate it...

Dora.
 
  • Like
Reactions: iVenky

    iVenky

    Points: 2
    Helpful Answer Positive Rating
Hello!

GPS can be interfaced quite easily with MSP430 (and I guess any other processor).
There is an example here. Quite old...
**broken link removed**
But I don't know how to simulate it...

I just finished blinking an led and also displaying the LCD using msp 430. My friend told me that we have pre defined functions / libraries available for all basic applications such as Serial communication, GPS etc. Do you have any idea about that?

Thanks in advance.
 

Hello!

GPS can be interfaced quite easily with MSP430 (and I guess any other processor).
There is an example here. Quite old...
**broken link removed**
But I don't know how to simulate it...

Dora.

Do you have the code for serial communication using msp430?

Waiting for your reply Doraemon.
 

Hello!

Why not using TI's sample code? There are many examples for each
peripheral. Many examples for ports, for uart, SPI, I2C, ADC, etc.
Download the samples set corresponding to your processor and you
will find examples that correspond almost 100% to what you want to
do. You will just have to change a few #define statements to make
the code suit your needs.

Dora.
 
  • Like
Reactions: iVenky

    iVenky

    Points: 2
    Helpful Answer Positive Rating
Hello!

Why not using TI's sample code? There are many examples for each
peripheral. Many examples for ports, for uart, SPI, I2C, ADC, etc.
Download the samples set corresponding to your processor and you
will find examples that correspond almost 100% to what you want to
do. You will just have to change a few #define statements to make
the code suit your needs.

Dora.

Oh. Thanks. I see that instead of numbers we are using characters to represent bit values of the registers in msp430. This needs headers. Do you have the list of those headers with their corresponding register strings(I don't know what you would call them)

Waiting for your reply doraemon.
 

Hello!

Sorry, I don't understand your question.
Inside of MSP430 (and I guess inside of any processor), register contain bits.
You can decide that these bits represent characters or integers, that's just up to
you. What I meant is, for example if in TI code, the chip select of one device is
on P4.0 and in your hardware on P5.3, then you redefine it like this. Let's suppose
it is an LCD:

Code:
#define LCD_CS_DIR  P5_DIR
#define LCD_CS_OUT  P5_OUT
#define LCD_CS        0x08
and in your code you can define:

Code:
void lcd_chip_select(uint8 select) {
    if(select) LCD_CS_OUT &= ~LCD_CS;
    else LCD_CS_OUT |= LCD_CS;
}
Or you can avoid defining a function and use a preprocessor macro:

#define LCD_SELECT LCD_CS_OUT &= ~LCD_CS
#define LCD_DESELECT LCD_CS_OUT |= LCD_CS

and so on. As a long time user of MSP430, I can tell you that usually TI code
works right out of the box. Well, out of the zip file. If one example is written
for USCIA0 and you want to use USCIB1, then replace A0 with B1 in their
code and it will work.

Dora.
 
  • Like
Reactions: iVenky

    iVenky

    Points: 2
    Helpful Answer Positive Rating
Hello!

Sorry, I don't understand your question.
Inside of MSP430 (and I guess inside of any processor), register contain bits.
You can decide that these bits represent characters or integers, that's just up to
you. What I meant is, for example if in TI code, the chip select of one device is
on P4.0 and in your hardware on P5.3, then you redefine it like this. Let's suppose
it is an LCD:

Code:
#define LCD_CS_DIR  P5_DIR
#define LCD_CS_OUT  P5_OUT
#define LCD_CS        0x08
and in your code you can define:

Code:
void lcd_chip_select(uint8 select) {
    if(select) LCD_CS_OUT &= ~LCD_CS;
    else LCD_CS_OUT |= LCD_CS;
}
Or you can avoid defining a function and use a preprocessor macro:

#define LCD_SELECT LCD_CS_OUT &= ~LCD_CS
#define LCD_DESELECT LCD_CS_OUT |= LCD_CS

and so on. As a long time user of MSP430, I can tell you that usually TI code
works right out of the box. Well, out of the zip file. If one example is written
for USCIA0 and you want to use USCIB1, then replace A0 with B1 in their
code and it will work.

Dora.

Actually what I meant is those strings like MC_1, ID_3, TASSEL_2, TACLR.
I know what they mean but there are many such strings like that.
Also to execute an interrupt we have to include intrinsics.h file. So I asked the list of some header files and their corresponding functions.

What I would like to do now is only GPS interfacing with MSP430. I am going to use msp430 only for that purpose. I saw the link that you mentioned before. But in there there are many parts of the program. Also I didn't understand what they were trying to do exactly.

What I want to do right now is this- I want to display the GPS data on the LCD. I have done serial communications before using other microcontrollers. I would be really happy if you could provide me the code. (Also try executing that code that you had mentioned before and tell me what to do ).

I would like to contact you too. But it seems like you have disabled privates messages. How can I contact you?


Waiting for your reply doraemon.

---------- Post added at 17:55 ---------- Previous post was at 17:53 ----------

My friend told that there are some predefined headers for GPS and some other applications like serial communications in the internet. Do you have any idea about that?
 

Hello!

MC_1, ID_3, etc are not strings, but hardware definitions. And TASSEL_2, TACLR
are related to timer setup. You don't need a timer if you just want to display GPS data.
What you need is to configure the MCU UART. Check the baud rate of your GPS
module, and set the same baud date to the CPU. I would advice to use either
an external crystal for the clock. If your processor allows it, use a high frequency
(a few MHz) as MCLK using FLL locked on the 32k crystal. If you have a HF crystal,
then use this external crystal. When you set the UART baud rate, set the UCBR
value according to your crystal. UCBR is for bit rate. Example: if you use a 8MHz
crystal (or if you set the frequency to 8MHz using FLL), and if your GPS talks at
115200 bps, then the UBR value will be 8000000/115200 which is 69. (I like this
value). It should work although it's not exactly 69.

- Connect your GPS to UART (depending on MSP430 type, UART RX and TX
can be called UTXD / URXD or UCxxRX / UXccTX, xx being A0, A1, B0, or B1.
By the way connect MCU's TX to GPS RX and vice versa, not TX on TX and RX on RX.
- Now receive the NMEA data buffer from the GPS device.
- Next, parse the data (see the sample code on the site I have referenced).
- Display the data.

As for the link I have posted earlier, sorry, but I don't understand what you don't
understand. Yes, there are a couple of function. What's the problem?
For example, function InitUsart0 initializes UART0. Do you have any problem in
understanding this? And USART0RecvBuffer receives a buffer of NMEA data.

Your program will therefore consist in:

Code:
uint8 NMEAData[DATA_LEN];

main () {
    [some initializations here, stop watch dog, initialize your LCD, etc..]
    InitUsart0(); // Initialize UART0
    while() {
        USART0RecvBuffer(NMEAData, DATA_LEN);
        ParseData(); // You have to write this one according to what output you want
        DisplayData(); // You have to write this one according to how you want to display your data
    }
}

Now please understand that I don't know which GPS, which MSP430 and which
LCD you use, so I cannot write a more detailed code. And beside this, I think you
should try to program instead of waiting that I write it for you.
Why not trying to write some code first and then ask questions if it doesn't work?

Dora.

PS: If you write code, please write SHORT functions. If one function is more than about 20 ~ 30
lines long, then split it. Whatever you write, be it the main program or some other function,
it should fit within one single screen so that you can see everything at once. If it's longer,
split it wisely. And if you ever post it, please use the appropriate formatting.
 
  • Like
Reactions: iVenky

    iVenky

    Points: 2
    Helpful Answer Positive Rating
Hello!

MC_1, ID_3, etc are not strings, but hardware definitions. And TASSEL_2, TACLR
are related to timer setup. You don't need a timer if you just want to display GPS data.
What you need is to configure the MCU UART. Check the baud rate of your GPS
module, and set the same baud date to the CPU. I would advice to use either
an external crystal for the clock. If your processor allows it, use a high frequency
(a few MHz) as MCLK using FLL locked on the 32k crystal. If you have a HF crystal,
then use this external crystal. When you set the UART baud rate, set the UCBR
value according to your crystal. UCBR is for bit rate. Example: if you use a 8MHz
crystal (or if you set the frequency to 8MHz using FLL), and if your GPS talks at
115200 bps, then the UBR value will be 8000000/115200 which is 69. (I like this
value). It should work although it's not exactly 69.

- Connect your GPS to UART (depending on MSP430 type, UART RX and TX
can be called UTXD / URXD or UCxxRX / UXccTX, xx being A0, A1, B0, or B1.
By the way connect MCU's TX to GPS RX and vice versa, not TX on TX and RX on RX.
- Now receive the NMEA data buffer from the GPS device.
- Next, parse the data (see the sample code on the site I have referenced).
- Display the data.

As for the link I have posted earlier, sorry, but I don't understand what you don't
understand. Yes, there are a couple of function. What's the problem?
For example, function InitUsart0 initializes UART0. Do you have any problem in
understanding this? And USART0RecvBuffer receives a buffer of NMEA data.

Your program will therefore consist in:

Code:
uint8 NMEAData[DATA_LEN];

main () {
    [some initializations here, stop watch dog, initialize your LCD, etc..]
    InitUsart0(); // Initialize UART0
    while() {
        USART0RecvBuffer(NMEAData, DATA_LEN);
        ParseData(); // You have to write this one according to what output you want
        DisplayData(); // You have to write this one according to how you want to display your data
    }
}

Now please understand that I don't know which GPS, which MSP430 and which
LCD you use, so I cannot write a more detailed code. And beside this, I think you
should try to program instead of waiting that I write it for you.
Why not trying to write some code first and then ask questions if it doesn't work?

Dora.

PS: If you write code, please write SHORT functions. If one function is more than about 20 ~ 30
lines long, then split it. Whatever you write, be it the main program or some other function,
it should fit within one single screen so that you can see everything at once. If it's longer,
split it wisely. And if you ever post it, please use the appropriate formatting.

Okay. Tomorrow I will first try serial communication. You said it's in the sample codes of TI right?
I just want to verify if that code for GPS is correct. If you have some time just execute it and tell me if it's working
I will keep posting about my progress and please do come to this thread and reply because I don't find people who have worked with msp430 before other than you:smile::smile:

Thank you
 

Hello!

No need to check, the code works.
But what you have to understand is that this is an extremely simple program,
and I think you should use the code on that site only as a reference, and write
your own code.

- Use a TI sample, and try to read 1 byte from your GPS. Do not write any
further code until you can read one byte from TI code.
- Once you get a single byte, write a kind of ReadBuffer function. Do not write
any further code until this function works. (you should get NMEA buffers at 1
second interval, although this interval depends on your GPS and its settings).
- Once you get NMEA buffers at 1 second interval, try to write a parser function
that extracts latitude and longitude. And similarly, don't write any further code
until this function works...
- And finally write a function that displays your data.

Dora.
 

Okay. I want to first check that using code composer. The msp that I am using is this- msp430fg461x/f20xx

I will try serial communication from the ti sample code right now in code composer.

Thanks

---------- Post added at 13:08 ---------- Previous post was at 13:04 ----------

Which among these is for serial communication?
File Name Description
--------------------------------------------------------------------------------
msp430x20x2_adc10_01.c ADC10, Sample A0, Set P1.0 if A0 > 0.5*AVcc
msp430x20x2_adc10_02.c ADC10, Sample A1, 1.5V Ref, Set P1.0 if A1 > 0.2V
msp430x20x2_adc10_03.c ADC10, ADC10, Sample A10 Temp, Set P1.0 if Temp ++ ~2C
msp430x20x2_adc10_04.c ADC10, ADC10, Sample A1, Signed, Set P1.0 if A1 > 0.5*AVcc
msp430x20x2_adc10_05.c ADC10, ADC10, Sample A11, Lo_Batt, Set P1.0 if AVcc < 2.3V
msp430x20x2_adc10_06.c ADC10, ADC10, Output Internal Vref on P1.4 & ADCCLK on P1.3
msp430x20x2_adc10_07.c ADC10, DTC Sample A1 32x, AVcc, Repeat Single, DCO
msp430x20x2_adc10_08.c ADC10, ADC10, DTC Sample A1 32x, 1.5V, Repeat Single, DCO
msp430x20x2_adc10_09.c ADC10, ADC10, DTC Sample A10 32x, 1.5V, Repeat Single, DCO
msp430x20x2_adc10_10.c ADC10, ADC10, DTC Sample A3-01, AVcc, Single Sequence, DCO
msp430x20x2_adc10_11.c ADC10, ADC10, Sample A1, 1.5V, TA1 Trig, Set P1.0 if > 0.5V
msp430x20x2_adc10_12.c ADC10, Sample A7, 1.5V, TA1 Trig, Ultra-Low Pwr
msp430x20x2_adc10_13.c ADC10, DTC Sample A1 32x, AVcc, TA0 Trig, DCO
msp430x20x2_adc10_14.c ADC10, DTC Sample A1-0 16x, AVcc, Repeat Seq, DCO
msp430x20x2_adc10_16.c ADC10, ADC10, DTC Sample A0 -> TA1, AVcc, DCO
msp430x20x2_adc10_temp.c ADC10, Sample A10 Temp and Convert to oC and oF
msp430x20x1_ca_01.c Comp_A, Output Reference Voltages on P1.1
msp430x20x1_ca_02.c Comp_A, Detect Threshold, Set P1.0 if P1.1 > 0.25*Vcc
msp430x20x1_ca_03.c Comp_A, Simple 2.2V Low Battery Detect
msp430x20x3_1.c Software Toggle P1.0
msp430x20x3_1_vlo.c Software Toggle P1.0, MCLK = VLO/8
msp430x20x3_clks.c Basic Clock, Output Buffered SMCLK, ACLK and MCLK/10
msp430x20xx_dco_flashcal.c DCO Calibration Constants Programmer
msp430x20x3_flashwrite_01.c Flash In-System Programming, Copy SegC to SegD
msp430x20x3_LFxtal_nmi.c LFXT1 Oscillator Fault Detection
msp430x20x3_lpm3.c Basic Clock, LPM3 Using WDT ISR, 32kHz ACLK
msp430x20x3_lpm3_vlo.c Basic Clock, LPM3 Using WDT ISR, VLO ACLK
msp430x20x3_nmi.c Basic Clock, Configure RST/NMI as NMI
msp430x20x3_P1_01.c Software Poll P1.4, Set P1.0 if P1.4 = 1
msp430x20x3_P1_02.c Software Port Interrupt Service on P1.4 from LPM4
msp430x20x3_P1_03.c Poll P1 With Software with Internal Pull-up
msp430x20x3_P1_04.c P1 Interrupt from LPM4 with Internal Pull-up
msp430x20x3_sd16A_01.c SD16A, Sample A1+ Continuously, Set P1.0 if > 0.3V
msp430x20x3_sd16A_02.c SD16, Using the Integrated Temperature Sensor
msp430x20x3_ta_01.c Timer_A, Toggle P1.0, CCR0 Cont. Mode ISR, DCO SMCLK
msp430x20x3_ta_02.c Timer_A, Toggle P1.0, CCR0 Up Mode ISR, DCO SMCLK
msp430x20x3_ta_03.c Timer_A, Toggle P1.0, Overflow ISR, DCO SMCLK
msp430x20x3_ta_04.c Timer_A, Toggle P1.0, Overflow ISR, 32kHz ACLK
msp430x20x3_ta_05.c Timer_A, Toggle P1.0, CCR0 Up Mode ISR, 32kHz ACLK
msp430x20x3_ta_06.c Timer_A, Toggle P1.0, CCR1 Cont. Mode ISR, DCO SMCLK
msp430x20x3_ta_07.c Timer_A, Toggle P1.0-2, Cont. Mode ISR, DCO SMCLK
msp430x20x3_ta_08.c Timer_A, Toggle P1.0-2, Cont. Mode ISR, 32kHz ACLK
msp430x20x3_ta_10.c Timer_A, Toggle P1.1/TA0, Up Mode, DCO SMCLK
msp430x20x3_ta_11.c Timer_A, Toggle P1.1/TA0, Up Mode, 32kHz ACLK
msp430x20x3_ta_13.c Timer_A, Toggle P1.1/TA0, Up/Down Mode, DCO SMCLK
msp430x20x3_ta_14.c Timer_A, Toggle P1.1/TA0, Up/Down Mode, 32kHz ACLK
msp430x20x3_ta_16.c Timer_A, PWM TA1-2, Up Mode, DCO SMCLK
msp430x20x3_ta_17.c Timer_A, PWM TA1, Up Mode, 32kHz ACLK
msp430x20x3_ta_19.c Timer_A, PWM TA1, Up/Down Mode, DCO SMCLK
msp430x20x3_ta_20.c Timer_A, PWM TA1, Up/Down Mode, 32kHz ACLK
msp430x20x3_ta_uart2400.c Timer_A, Ultra-Low Pwr UART 2400 Echo, 32kHz ACLK
msp430x20x3_usi_01.c USICNT Used as a One-Shot Timer Function, DCO SMCLK
msp430x20x3_usi_02.c SPI full-Duplex 3-wire Master
msp430x20x3_usi_03.c SPI full-Duplex 3-wire Slave
msp430x20x3_usi_04.c USI SPI Interface with HC165/164 Shift Registers
msp430x20x3_usi_05.c USI SPI Interface to TLC549 8-bit ADC
msp430x20x3_usi_06.c I2C Master Receiver, single byte
msp430x20x3_usi_07.c I2C Master Transmitter, single byte
msp430x20x3_usi_08.c I2C Slave Receiver, single byte
msp430x20x3_usi_09.c I2C Slave Transmitter, single byte
msp430x20x3_wdt_01.c WDT, Toggle P1.0, Interval Overflow ISR, DCO SMCLK
msp430x20x3_wdt_02.c WDT, Toggle P1.0, Interval Overflow ISR, 32kHz ACLK
msp430x20x3_wdt_04.c WDT+ Failsafe Clock, DCO SMCLK
msp430x20x3_wdt_05.c Reset on Invalid Address fetch, Toggle P1.0
msp430x20x3_wdt_06.c WDT+ Failsafe Clock, 32kHz ACLK
msp430x20x3_dco_calib.c Basic Clock with preloaded DCO calibration constants
msp430x20x3_sd16A_03.c The SD16A sample of a single sequence of channels
msp430x20x3_usi_10.c I2C Master Receiver Multiple Bytes
msp430x20x3_usi_11.c I2C Master Transmitter Multiple Bytes
msp430x20x3_usi_12.c I2C Master Transmitter / Receiver, Multiple Bytes (no rpt st)
msp430x20x3_usi_13.c I2C Slave Receiver, Multiple Bytes (to be used with usi_11)
msp430x20x3_usi_14.c I2C Slave Transmitter, multiple bytes (to be used with usi_10)
msp430x20x3_usi_15.c I2C Slave Receiver Universal code (to be used with usi_12)
msp430x20x3_usi_16.c I2C Master Transmitter / Reciever, Repeated Start (to be used with usi_15)
msp430x20x3_wdt_07.c WDT+ periodic reset

---------- Post added at 13:10 ---------- Previous post was at 13:08 ----------
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top