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.

[General] How to bring the adc data to io port of msp430

Status
Not open for further replies.

santh92

Junior Member level 1
Joined
Sep 8, 2014
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,487
Hi sir,

i have configured an channel of adc in msp430f5438a microcontroller.

Now i have the converted data in adc12mem0(0)(for adc channel0).

Is there any possibility to bring the data to the i/o of msp430 controller or led from adc12mem0 register

if it is possible please help me how to do it.

Thanks to read my quory..........
 

Hello!

Bringing the raw data to a port? Why not PxOUT = ADC12MEM0? Now bear in mind
that ADC12MEM0 is 12 bit and the port possibly 8 bit, except if you have a recent device
with 16 bits ports. Example:

PBDIR = 0xFFFF;

Then PBOUT = ADC12MEM, and you should get the 12 bits in the 16 bits of PB.

Dora.
 
Thank you for reply sir,

but i have 16-bit register ADC12MEM0 in msp430f5438a microcontroller
-> in my controller devices each port is having 8 pin...... P1.0 to P1.7
-> give me some clarifications for below ques:
1. may i seperate the data like ADC12MEM0(0 th bit), ADC12MEM0 (1 st bit)..... ADC12MEM0 (12th bit)... previously i have some working experience with fpga.. in there i can collect my as a digital form......
2. is there any possibility to bring down that separate data of ADC12MEM0 (0 th bit) , ADC12MEM0 (1 st bit).... to P1.6, P2.4 respectively.??

Thank you sir....
 

Hello!

1. If you are using MSP430F5438A, you have some 16 bit ports, PA to PE.
You can do PBDIR |= 0xFFFF; // Leave PA because it's interrupt capable and you can use it for something else.
Then PBOUT = ADC12MEMx

2. You can do pretty much all what you want. If you want to display bit per bit, that's your choice.

If you want for example activate P2.4 from bit 9 of ADC12MEM0, you can do:

if(ADC12MEM0 & 0x0400) P2OUT |= 0x10;

That's about it.

Dora.
 
Thank you so much..... sir

your solution is very helpful to me..... 1st sol is working fine...
but i tried for 2nd one...... the bit position is changing, so i couldn't identify the corresponding value for my signal.........

little bit variation is there in the output sample value of adc (3815, 3817, 3823, 3810, 3808).... in 12 bit resolution.... is there any solution to rectify it............?
 

Dear doraemon,

I have already discussed with you to collect the data from msp430f5438a microcontroller and i am using EXP-MSP430F5438 Microcontroller.
I want to know, while collecting data from the ADC12MEM register is there any delay will be occur. Or is there any way to do synchronization with the clock while collecting the data from the register.
I am directly accessing data from the register and giving it to Logic analyzer(16806A). Is it wright way??
Please give me some idea...
Thank you,

by
Prasanth S
 

Hi,

To synchronoze you need to output a "sync signal" with every new data:
Code:
- output data low
- output data high
- set sync pin
- clear sync pin
... loop with each sample

Why don't you use an ADC with parallel outputs?

Don't use LEDs. Because the LED current through the chip will influence ADC operation.
--> Increased noise, increased DNL, increased INL.

Klaus
 

thank you KlausST,

I am attaching my code below, please tell me where i have to add those steps :

Code:
#include "msp430f5438A.h"
#include <stdio.h>
void adc_function(void);

void main(void)
{
  
  WDTCTL = WDTPW+WDTHOLD;                   // Stop watchdog timer 
  adc_function();

  __bis_SR_register(LPM4_bits + GIE);       // Enter LPM4, Enable interrupts
  __no_operation();                         // For debugger  

}

void adc_function(void)
{
  P6SEL |= 0x80;                            // Enable A/D channel A7
  PBDIR |= 0xFFFF;
  
  REFCTL0 = REFMSTR + REFON + REFVSEL_2 + REFTCOFF;
  
  ADC12CTL0 = ADC12ON+ADC12SHT0_1 + ADC12MSC; 
              
  ADC12CTL1 = ADC12CSTARTADD_7 + ADC12SHP + ADC12SHS_0 + ADC12DIV_0 + ADC12SSEL_0 + ADC12CONSEQ_2;
                     
  ADC12CTL2 = ADC12RES_2;
              
  ADC12MCTL7 = ADC12SREF_1 + ADC12INCH_7;

  ADC12CTL0 |= ADC12ENC;
  ADC12CTL0 |= ADC12SC;
  ADC12IE  |= ADC12IE7; 
}

// INTERRUPT VECTORS FOR MSP430 ////////////////////////////////////////

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
#else
#error Compiler not supported!
#endif
{
  switch(__even_in_range(ADC12IV,34))
  {
  case  0: break;     // Vector  0:  No interrupt
  case  2: break;     // Vector  2:  ADC overflow
  case  4: break;     // Vector  4:  ADC timing overflow
  case  6: break;     // Vector  6:  ADC12IFG0   
  case  8: break;     // Vector  8:  ADC12IFG1
  case 10: break;     // Vector 10:  ADC12IFG2
  case 12: break;     // Vector 12:  ADC12IFG3
  case 14: break;     // Vector 14:  ADC12IFG4
  case 16: break;     // Vector 16:  ADC12IFG5
  case 18: break;     // Vector 18:  ADC12IFG6
  case 20:            // Vector 20:  ADC12IFG7
        PBOUT = ADC12MEM7;
  case 22: break;     // Vector 22:  ADC12IFG8
  case 24: break;     // Vector 24:  ADC12IFG9
  case 26: break;     // Vector 26:  ADC12IFG10
  case 28: break;     // Vector 28:  ADC12IFG11
  case 30: break;     // Vector 30:  ADC12IFG12
  case 32: break;     // Vector 32:  ADC12IFG13
  case 34: break;     // Vector 34:  ADC12IFG14
  default: break; 
  }
}
 
Last edited by a moderator:

Hi,

I´m not familiar with writing C.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top