Estoy intentando hacer un programa con mi MSP430FR6989 de Texas Instruments. yo enviar una señal analógica a mi módulo ADC en la unidad uC, que la convierte en una señal digital, si el valor es mayor que 0x800 ( 1.65 V ), configure un LED azul , de lo contrario apaga el LED azul
Estoy tratando de hacer eso con interrupciones.
Este es un fragmento de mi código
EDIT2 Agregué el código completo en lugar del fragmento
#include <msp430.h>
#define ENABLE_PINS 0xFFFE
void ADC_SETUP (void);
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
PM5CTL0 = ENABLE_PINS;
P4DIR = BIT3;
ADC_SETUP ();
ADC12IER0 = ADC12IE0;
_BIS_SR(GIE);
ADC12CTL0 = ADC12CTL0 | ADC12ENC;
ADC12CTL0 = ADC12CTL0 | ADC12SC;
while(1);
return 0;
}
void ADC_SETUP (void)
{
#define ADC12_SHT_16 0x0200
#define ADC12_ON 0x0010
#define ADC12_SHT_SRC_SEL 0x0200
#define ADC12_12BIT 0x0020
#define ADC12_P92 0x000A
ADC12CTL0 = ADC12_SHT_16 | ADC12_ON;
ADC12CTL1 = ADC12_SHT_SRC_SEL;
ADC12CTL2 = ADC12_12BIT;
ADC12MCTL0 = ADC12_P92;
}
#pragma vector = ADC12_VECTOR//0xFFEA//ADC12_VECTOR
__interrupt void ADC12_ISR (void)
{
if(ADC12MEM0 > 0x0800)
P4OUT = BIT3;
else
P4OUT = 0x00;
ADC12CTL0 = ADC12CTL0 | ADC12SC;
}
cuando lo construyo recibo esta advertencia.
# 2580-D pragma vector = acepta argumentos numéricos o "unused_interrupt" pero no ADC12_VECTOR
Cuando lo depuro, y mi uC va a Línea A y el bit ADC12SC está configurado, va a isr_trap.asm , y mi uC está atascada allí
Por favor, ayúdame con este problema.
Inicio de EDIT_0
MSP430FR6989
Code Composer Studio 6.1.0
Compilador: TI v4.4.3
Fin de EDIT_0
Inicio de EDIT_1
No puedo copiar y pegar el archivo .map aquí porque es demasiado pequeño, ya que excedí el límite de caracteres para esta publicación.
En cambio, copié el archivo en un archivo de texto y lo envié a este enlace.
Se llama ADC_ISR_UDEMY.map.txt
Fin de EDIT_1
Inicio de EDIT_3
Lo siento por la respuesta tardía, aprecio la ayuda de todos en este hilo.
Intenté hacer 3 proyectos, uno con Timer A0 CCR0 ISR ( ISR_TRAP_TIMER_TEST ), uno con ADC12_B ISR ( ISR_TRAP_ADC_TEST ), y uno con ADC12_B isr con @GVelascoh Header ( ISR_TRAP_ADC_HEADER_2 )
ISR_TRAP_TIMER_TEST funcionó bien, el LED P1.0 estaba parpadeando
#include <msp430.h>
#define ENABLE_PINS 0xFFFE
void init_Timer (void);
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
PM5CTL0 = ENABLE_PINS;
P1DIR = BIT0;
init_Timer ();
_BIS_SR(GIE);
while(1);
return 0;
}
void init_Timer (void)
{
TA0CTL = TASSEL__ACLK | MC__UP;
TA0CCR0 = 3000;
TA0CCTL0 = CCIE;
}
#pragma vector = TIMER0_A0_VECTOR //TA0 CCR0
__interrupt void Test_ISR (void)
{
P1OUT = P1OUT ^ BIT0;
//clear the flag
}
Construir:
**** Build of configuration Debug for project ISR_TRAP_TIMER_TEST ****
"C:\ti\ccsv6\utils\bin\gmake" -k all
'Building file: ../main.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/bin/cl430" -vmspx --abi=eabi --data_model=restricted --use_hw_mpy=F5 --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/include" --advice:power=all --advice:hw_config=all -g --define=__MSP430FR6989__ --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
"../main.c", line 19: warning #112-D: statement is unreachable
"../main.c", line 17: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
'Finished building: ../main.c'
' '
'Building target: ISR_TRAP_TIMER_TEST.out'
'Invoking: MSP430 Linker'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/bin/cl430" -vmspx --abi=eabi --data_model=restricted --use_hw_mpy=F5 --advice:power=all --advice:hw_config=all -g --define=__MSP430FR6989__ --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal -z -m"ISR_TRAP_TIMER_TEST.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv6/ccs_base/msp430/include" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/include" -i"C:/ti/ccsv6/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv6/ccs_base/msp430/lib/FR59xx" --reread_libs --priority --warn_sections --display_error_number --diag_wrap=off --xml_link_info="ISR_TRAP_TIMER_TEST_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "ISR_TRAP_TIMER_TEST.out" "./main.obj" "../lnk_msp430fr6989.cmd" -l"libmath.a" -l"libc.a"
<Linking>
remark #10372-D: (ULP 4.1) Detected uninitialized Port A in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port B in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port C in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port D in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port E in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
'Finished building target: ISR_TRAP_TIMER_TEST.out'
' '
**** Build Finished ****
ISR_TRAP_ADC_TEST El uC todavía va a la isr_trap.asm
#include <msp430.h>
#define ENABLE_PINS 0xFFFE
void init_ADC (void);
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
PM5CTL0 = ENABLE_PINS;
P1DIR = BIT0;
init_ADC ();
_BIS_SR(GIE);
ADC12CTL0 = ADC12CTL0 | ADC12ENC;
ADC12CTL0 = ADC12CTL0 | ADC12SC;
while(1);
return 0;
}
void init_ADC (void)
{
ADC12CTL0 = ADC12ON | ADC12SHT0_2;
ADC12CTL1 = ADC12SHP;
ADC12CTL2 = ADC12RES__12BIT;
ADC12MCTL0 = ADC12INCH_10;
ADC12IER0 = ADC12IE0;
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR (void)
{
if(ADC12MEM0 > 0x0800)
P1OUT = BIT0;
else
P1OUT = 0x00;
}
Construir:
**** Build of configuration Debug for project ISR_TRAP_ADC_TEST ****
"C:\ti\ccsv6\utils\bin\gmake" -k all
'Building file: ../main.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/bin/cl430" -vmspx --abi=eabi --data_model=restricted --use_hw_mpy=F5 --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/include" --advice:power=all --advice:hw_config=all -g --define=__MSP430FR6989__ --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
"../main.c", line 22: warning #112-D: statement is unreachable
"../main.c", line 20: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
"../main.c", line 35: warning #2580-D: pragma vector= accepts numeric arguments or "unused_interrupts" but not ADC12_VECTOR
'Finished building: ../main.c'
' '
'Building target: ISR_TRAP_ADC_TEST.out'
'Invoking: MSP430 Linker'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/bin/cl430" -vmspx --abi=eabi --data_model=restricted --use_hw_mpy=F5 --advice:power=all --advice:hw_config=all -g --define=__MSP430FR6989__ --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal -z -m"ISR_TRAP_ADC_TEST.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv6/ccs_base/msp430/include" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/include" -i"C:/ti/ccsv6/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv6/ccs_base/msp430/lib/FR59xx" --reread_libs --priority --warn_sections --display_error_number --diag_wrap=off --xml_link_info="ISR_TRAP_ADC_TEST_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "ISR_TRAP_ADC_TEST.out" "./main.obj" "../lnk_msp430fr6989.cmd" -l"libmath.a" -l"libc.a"
<Linking>
remark #10372-D: (ULP 4.1) Detected uninitialized Port A in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port B in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port C in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port D in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port E in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
'Finished building target: ISR_TRAP_ADC_TEST.out'
' '
**** Build Finished ****
ISR_TRAP_ADC_HEADER_2 Todavía tengo el mismo problema, donde la unidad de usuario va a isr_trap.asm (espero haber agregado su encabezado a la derecha @GVelascoh)
#include <msp430.h>
#define ENABLE_PINS 0xFFFE
void init_ADC (void);
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
PM5CTL0 = ENABLE_PINS;
P1DIR = BIT0;
init_ADC ();
_BIS_SR(GIE);
ADC12CTL0 = ADC12CTL0 | ADC12ENC;
ADC12CTL0 = ADC12CTL0 | ADC12SC;
while(1);
return 0;
}
void init_ADC (void)
{
ADC12CTL0 = ADC12ON | ADC12SHT0_2;
ADC12CTL1 = ADC12SHP;
ADC12CTL2 = ADC12RES__12BIT;
ADC12MCTL0 = ADC12INCH_10;
ADC12IER0 = ADC12IE0;
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
if(ADC12MEM0 > 0x0800)
P1OUT = BIT0;
else
P1OUT = 0x00;
}
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12_ISR (void)
#else
#error Compiler not supported!
#endif
Construir:
**** Build of configuration Debug for project ISR_TRAP_ADC_HEADER_2 ****
"C:\ti\ccsv6\utils\bin\gmake" -k all
'Building file: ../main.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/bin/cl430" -vmspx --abi=eabi --data_model=restricted --use_hw_mpy=F5 --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/include" --advice:power=all --advice:hw_config=all -g --define=__MSP430FR6989__ --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
"../main.c", line 23: warning #112-D: statement is unreachable
"../main.c", line 21: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
"../main.c", line 37: warning #2580-D: pragma vector= accepts numeric arguments or "unused_interrupts" but not ADC12_VECTOR
'Finished building: ../main.c'
' '
'Building target: ISR_TRAP_ADC_HEADER_2.out'
'Invoking: MSP430 Linker'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/bin/cl430" -vmspx --abi=eabi --data_model=restricted --use_hw_mpy=F5 --advice:power=all --advice:hw_config=all -g --define=__MSP430FR6989__ --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal -z -m"ISR_TRAP_ADC_HEADER_2.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv6/ccs_base/msp430/include" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/include" -i"C:/ti/ccsv6/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv6/ccs_base/msp430/lib/FR59xx" --reread_libs --priority --warn_sections --display_error_number --diag_wrap=off --xml_link_info="ISR_TRAP_ADC_HEADER_2_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "ISR_TRAP_ADC_HEADER_2.out" "./main.obj" "../lnk_msp430fr6989.cmd" -l"libmath.a" -l"libc.a"
<Linking>
remark #10372-D: (ULP 4.1) Detected uninitialized Port A in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port B in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port C in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port D in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port E in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
'Finished building target: ISR_TRAP_ADC_HEADER_2.out'
' '
**** Build Finished ****
Fin de EDIT_3
Inicio de EDIT_4
Gracias por su ayuda, solucioné mi problema, desinstalé CCS v6.1.0 e instalé CCS 8.2.0, escribí el mismo programa y el problema desapareció.
Pensé que comparto esto, así que no lo dejaré colgado.
Saludos,
Forat
Fin de EDIT_4