Part Number: MSP430F6736
Tool/software: Code Composer Studio
Hi team,
I want to use 6 analog input lines for the msp430f6736 (100 pin). Inputs from A0-A5.
I have gone through the example code that uses 3 input lines. Here is the example code:
#include <msp430.h>
unsigned char ADC_Result[3]; // 8-bit ADC conversion result array
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Setup P1.2 A0, 1.1 A1, 1.0 A2
P1SEL |= BIT0 | BIT1 | BIT2; // Set P1.0,.1,.2 to non-IO
__disable_interrupt(); // Disable interrupts; Port Map cnfg
PMAPKEYID = PMAPKEY; // Enable access Port Mapping regs
P1MAP2 = PM_ANALOG; // Enable A0
P1MAP1 = PM_ANALOG; // Enable A1
P1MAP0 = PM_ANALOG; // Enable A2
PMAPKEYID = 0; // Disable access Port Mapping regs
__enable_interrupt(); // Re-enable all interrupts
// Setup ADC10
ADC10CTL0 = ADC10SHT_2 | ADC10MSC | ADC10ON; // 16ADCclks, MSC, ADC ON
ADC10CTL1 = ADC10SHP | ADC10CONSEQ_1; // pulse sample mode, sngle sequence
ADC10CTL2 &= ~ADC10RES; // 8-bit resolution
ADC10MCTL0 = ADC10INCH_2; // A0,A1,A2(EoS), AVCC reference
// Setup DMA0 (ADC10IFG trigger)
DMACTL0 = DMA0TSEL_24; // ADC10IFG trigger
DMA0SZ = 0x03; // 3 conversions
__data16_write_addr((unsigned short) &DMA0SA, (unsigned long) &ADC10MEM0);
// Source single address
__data16_write_addr((unsigned short) &DMA0DA, (unsigned long) &ADC_Result[0]);
// Destination array address
DMA0CTL = DMADT_4 | DMADSTINCR_3 | DMASRCBYTE | DMADSTBYTE | DMAEN | DMAIE;
// Repeated single transfer
// Increment destination
// Byte access
// Enable int after seq of convs
while (1)
{
while (ADC10CTL1 & ADC10BUSY) ; // Wait if ADC10 core is active
ADC10CTL0 |= ADC10ENC | ADC10SC; // Sampling and conversion start
__bis_SR_register(LPM0_bits | GIE); // Enter LMP0 w/ interrupt
__delay_cycles(5000); // Delay between sequence convs
__no_operation(); // BREAKPOINT; View ADC_Result
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=DMA_VECTOR
__interrupt void DMA0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(DMA_VECTOR))) DMA0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch (__even_in_range(DMAIV, 16))
{
case DMAIV_NONE: break; // No interrupts
case DMAIV_DMA0IFG: // DMA0IFG = DMA Channel 0
// sequence of conversions complete
__bic_SR_register_on_exit(LPM0_bits); // exit LPM0 on return
break;
case DMAIV_DMA1IFG: break; // DMA1IFG = DMA Channel 1
case DMAIV_DMA2IFG: break; // DMA2IFG = DMA Channel 2
case 8: break; // Reserved
case 10: break; // Reserved
case 12: break; // Reserved
case 14: break; // Reserved
case 16: break; // Reserved
default: break;
}
}
I tried and printed the outputs of all the 3 inputs by setting breakpoints. I got outputs with respect to 8-bit resolution.
I tried and changed:
ADC10CTL2 &= ~ADC10RES; // 8-bit resolution
to ADC10CTL2 |= ADC10RES; // 10-bit resolution
but it did not change to 10-bit resolution.
What do I need to change to get a 10-bit resolution?
The analog inputs A3-A5 are on port 9.
how do I add those inputs to this code so that I can get the outputs of all the 6 analog inputs on the screen?
could you help me out with this issue?
Thank you,
Keval