Part Number: MSP430G2744
Tool/software: Code Composer Studio
Goodmorning Everybody!
I have some debugging troubles with the code I wrote, but first of all let me explain a bit more about my program.
I want my little keyboard with UP and DOWN buttons to change a value on the display by incrementing or decrementing a start point value and, in the ISR of the TIMER A, I need to call my .asm function every 10ms so that I would be able to know if the general button (that is my variable TASTO) is or not pressed by the user.
After reading that value I call the .c function "button_pushed" for doing some different operations in the case the button pushed is UP or DOWN button.
I have a .c header file shared with an .asm file: here there are the definitions of all the variables and functions I want to use in the .asm file.
In this header file I declared the variable TASTO as follows:
extern unsigned char TASTO;
In the .asm file I wrote something like this:
.bss TASTO, 1
.global TASTO
and until this point everything looks fantastic: infact when I compile my code I haven't any errors and warnings.
But unfortunately I can't tell the same for the debug step because my program doesn't do what I want (as described above).
It seems like the linker file doesn't match the variable TASTO decleared in .c header file with the variable that I'm using in the .asm function.
Is it possible? Have I write something wrong?
Which is the easiest way to declare a variable in C header file and use it in .asm file, sharing that header file?
(The files mantioned before are attached to this post).
I hope someone could really help me to find out a solution so that I can proceed with my work.
Thank You very much for the attention,
Kind Regards,
Maria Angela
; /***********************************************************************************************************
; * Tastiera.asm
; ***********************************************************************************************************/
; /* Created on: 24 luglio 2017
; * Author: Maria Angela Cianci
; */
;***************************************************************************************************************
; La macro tastiera gestisce la pressione dei tasti e la funzione del tasto premuto, purch� il dat gli arrivi
; all'interno del registro R4 in posizione LSB. Questa sar� poi la funzione che vado a chiamare per il
; controllo della tastiera (tasto premuto o no, per quanto tempo, ecc...).
;***************************************************************************************************************
;***************************************************************************************************************
; La direttiva cdecl mi permettere di includere i vari header file di cui ho bisogno per il funzionamento
; del programma.
;***************************************************************************************************************
.cdecls C,LIST, "msp430g2744.h"
.cdecls C,LIST, "Definizioni_Tastiera.h"
.align 2
.bss TASTO,1
.bss OLD_TASTO,1
.bss PRENDITASTO,1
.bss FLAG_VARI,2,2
.bss TIMER_BLINK,1
.bss TIMER_TASTOSOLO,1
.text
.global TASTO
.global OLD_TASTO
.global tastiera_standard
tastiera_standard: .asmfunc
push.w R5
mov.b P2IN, R5
inv.b R5
and.b #00111111b, R5
cmp.b OLD_TASTO, R5
jeq tasto_premuto
ritasto: mov.b R5, OLD_TASTO
clr.b TASTO
bic.w #(FLAG_TASTOCONTINUO+FLAG_TASTOSOLO+FLAG_TASTOPREMUTO),FLAG_VARI
mov.b #CAMPIONI_TASTI, PRENDITASTO
clr.b TIMER_TASTOSOLO
br #tastiera_exit
tasto_premuto: bit.w #(FLAG_TASTOCONTINUO+FLAG_TASTOSOLO+FLAG_TASTOPREMUTO),FLAG_VARI
jne PRESO
dec.b PRENDITASTO
jn PRESO
mov.b R5, OLD_TASTO
br #tastiera_exit
PRESO: mov.b #CAMPIONI_TASTI, PRENDITASTO
mov.b OLD_TASTO, TASTO
tst.b TASTO
jeq ritasto
bit.b #TIMER_BLINK800,TIMER_TASTOSOLO
jne tasto_continuo
bit.w #(FLAG_TASTOCONTINUO + FLAG_TASTOSOLO),FLAG_VARI
jne tastiera_exit
bis.w #FLAG_TASTOSOLO, FLAG_VARI
bic.b #FLAG_TASTOCONTINUO, FLAG_VARI
br #tastiera_exit
tasto_continuo: bis.b #TIMER_BLINK800, TIMER_TASTOSOLO
bis.w #FLAG_TASTOCONTINUO, FLAG_VARI
bic.w #FLAG_TASTOSOLO, FLAG_VARI
tastiera_exit:
pop.w R5
ret
.endasmfunc
/************************************************************************************************************
* Routine_Tastiera.c
***********************************************************************************************************/
/* Created on: 26 luglio 2017
* Author: Maria Angela Cianci
*/
#include <msp430.h>
#include <Board_Initialization.h>
#include <Definizioni_Tastiera.h>
#include <Definizioni_Display.h>
void botton_pushed (unsigned char tasto) {
unsigned char tasto_up;
unsigned char tasto_down;
tasto_up=TASTO_UP;
tasto_down=TASTO_DOWN;
tasto=TASTO;
if(tasto==tasto_up) {
VALUE++;
Temp_Setpoint=VALUE;
}
if(tasto==tasto_down) {
VALUE--;
Temp_Setpoint=VALUE;
}
else {
VALUE;
Temp_Setpoint=VALUE;
}
}
/************************************************************************************************************
* Definizioni_Tastiera.h
***********************************************************************************************************/
/* Created on: 24 luglio 2017
* Author: Maria Angela Cianci
*/
/************************************************************************************************************
* DEFINIZIONI DELLE MASCHERE DEI TASTI
* Associa ogni PIN della porta 2 ad un determinato tasto sulla tastiera.
*
***********************************************************************************************************/
#define TASTO_UP 0b00001000
#define TASTO_DOWN 0b00000010
extern unsigned char TASTO;
extern unsigned char OLD_TASTO;
unsigned int Temp_Setpoint;
extern void tastiera_standard();
void botton_pushed (unsigned char tasto);
/**************************************************************************
* PROGETTO EL_0002_17_V00
* Created on: 22 giugno 2017
* Poject Name: SOUS COOKER SEMIPROFESSIONAL
* Mcu: MSP430G2744
* Author: Maria Angela Cianci
*************************************************************************/
#include <msp430.h>
#include <Clear_RAM.h>
#include <Watchdog.h>
#include <Board_Initialization.h>
#include <Tlv_Structure.h>
#include <Definizioni_Tastiera.h>
#include <Definizioni_Display.h>
#include <Timer_Variable.h>
/**************************************************************************
* MAIN *
*************************************************************************/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; //watchdog_disable;
/* Inizializzo lo stack pointer al valore 0x5FF in fondo alla RAM */
__asm (" MOV.W #0x0600,SP");
clear_RAM();
delay_watchdog(wdt_delay);
watchdog_enable();
configurazione_iniziale();
Temp_Setpoint=100;
VALUE=Temp_Setpoint;
display_initialization();
while (1) {
watchdog();
botton_pushed(TASTO);
display_startup(VALUE); --> routine to display the value on 8-segment 4 digit display
}
}