Bryan Cisneros
/
DebugMonitor
Revision 1:9fa7cc80f1a7, committed 2019-10-04
- Comitter:
- bcis93
- Date:
- Fri Oct 04 22:03:30 2019 +0000
- Parent:
- 0:4fb921928934
- Commit message:
- compiled;
Changed in this revision
--- a/ADC_input.cpp Fri Oct 04 21:09:15 2019 +0000 +++ b/ADC_input.cpp Fri Oct 04 22:03:30 2019 +0000 @@ -49,6 +49,10 @@ #define CHANNEL_1 (1U) #define CHANNEL_2 (2U) +uint16_t ADC_vortex_frequency_input = 0; +uint16_t Vrefl = 0; +uint16_t Vtemp = 0; + AnalogIn Vref_low(ch0); AnalogIn vortex_frequency(ch1);
--- a/Calculate_flow.cpp Fri Oct 04 21:09:15 2019 +0000 +++ b/Calculate_flow.cpp Fri Oct 04 22:03:30 2019 +0000 @@ -43,7 +43,7 @@ #define PID_METERS (0.07366) #define INCHES_IN_METER (39.37) - +uint16_t flow = 0; float calculateViscosity(uint16_t temperature) {
--- a/Monitor.cpp Fri Oct 04 21:09:15 2019 +0000 +++ b/Monitor.cpp Fri Oct 04 22:03:30 2019 +0000 @@ -50,6 +50,12 @@ *******************************************************************************/ +#define NUMBER_OF_REGISTERS (16) +#define NUM_ADDR_TO_PRINT (5) +#define MEMORY_STARTING_ADDR (0x200) + +extern UCHAR error_count; + __asm uint32_t getregister(uint32_t x){ @@ -83,8 +89,8 @@ BEQ return_from_function_r13 CMP r0,#14; BEQ return_from_function_r14 - // CMP r0,#15; - // BEQ return_from_function_r15 + CMP r0,#15; + BEQ return_from_function_r15 return_from_function_r0 MOV r0,r0 ; store the return value in r0 @@ -131,10 +137,9 @@ return_from_function_r14 MOV r0,r14 ; store the return value in r0 BLX lr ; Else return from subroutine with link and returning the value of register -//return_from_function_r15 - - // MOV r0,15 ; store the return value in r0 - // BLX lr ; Else return from subroutine with link and returning the value of register +return_from_function_r15 + MOV r0,r15 ; store the return value in r0 + BLX lr ; Else return from subroutine with link and returning the value of register } __asm uint32_t getregister0(void){ @@ -223,12 +228,12 @@ { UCHAR chr,err=0; // unsigned char data; + chr = msg_buf[0]; - if( (chr = msg_buf[0]) <= 0x60 ) - { // Upper Case - switch( chr ) - { + + switch( chr ) + { case 'D': if((msg_buf[1] == 'E') && (msg_buf[2] == 'B') && (msg_buf_idx == 3)) { @@ -273,17 +278,8 @@ default: err = 1; - } - } + } - else - { // Lower Case - switch( chr ) - { - default: - err = 1; - } - } if( err == 1 ) { @@ -345,16 +341,17 @@ { if (display_flag == 1) { // resets and sets continous receive enable bit - UART_msg_put("\r\nNORMAL "); + UART_direct_msg_put("\r\nNORMAL "); UART_direct_msg_put(" Flow: "); - // ECEN 5803 add code as indicated - UART_direct_hex_put(flow); + // ECEN 5803 add code as indicated + // add flow data output here, use UART_hex_put or similar for + // numbers UART_direct_msg_put(" Temp: "); - // ECEN 5803 add code as indicated - UART_direct_hex_put(temperature); + // add flow data output here, use UART_hex_put or similar for + // numbers UART_direct_msg_put(" Freq: "); - // ECEN 5803 add code as indicated - UART_direct_hex_put(freq_value); + // add flow data output here, use UART_hex_put or similar for + // numbers display_flag = 0; } } @@ -366,13 +363,14 @@ UART_direct_msg_put("\r\nDEBUG "); UART_direct_msg_put(" Flow: "); // ECEN 5803 add code as indicated - UART_direct_hex_put(flow); + // add flow data output here, use UART_hex_put or similar for + // numbers UART_direct_msg_put(" Temp: "); - // ECEN 5803 add code as indicated - UART_direct_hex_put(temperature); + // add flow data output here, use UART_hex_put or similar for + // numbers UART_direct_msg_put(" Freq: "); - // ECEN 5803 add code as indicated - UART_direct_hex_put(freq_value); + // add flow data output here, use UART_hex_put or similar for + // numbers /**************** ECEN 5803 add code as indicated ***************/ @@ -382,62 +380,66 @@ /* Define varables to store registers*/ /**********************************/ //Assembly language call to function to get ARM registers (R0-R15) - - uint32_t register0 = getregister0(); - uint32_t register1 = getregister(1); - uint32_t register2 = getregister(2); - uint32_t register3 = getregister(3); - uint32_t register4 = getregister(4); - uint32_t register5 = getregister(5); - uint32_t register6 = getregister(6); - uint32_t register7 = getregister(7); - uint32_t register8 = getregister(8); - uint32_t register9 = getregister(9); - uint32_t register10 = getregister(10); - uint32_t register11 = getregister(11); - uint32_t register12 = getregister(12); - uint32_t register13 = getregister(13); - uint32_t register14 = getregister(14); - //uint32_t register15 = getregister(15); // Write code to get register 15 - // Display registers - UART_direct_msg_put("\r\nARM REGISTERS[R0-R15]:"); - UART_direct_msg_put("\r\nREGISTER0:"); - UART_direct_hex_put_word(register0); - UART_direct_msg_put("\r\nREGISTER1:"); - UART_direct_hex_put_word(register1); - UART_direct_msg_put("\r\nREGISTER2:"); - UART_direct_hex_put_word(register2); - UART_direct_msg_put("\r\nREGISTER3:"); - UART_direct_hex_put_word(register3); - UART_direct_msg_put("\r\nREGISTER4:"); - UART_direct_hex_put_word(register4); - UART_direct_msg_put("\r\nREGISTER5:"); - UART_direct_hex_put_word(register5); - UART_direct_msg_put("\r\nREGISTER6:"); - UART_direct_hex_put_word(register6); - UART_direct_msg_put("\r\nREGISTER7:"); - UART_direct_hex_put_word(register7); - UART_direct_msg_put("\r\nREGISTER8:"); - UART_direct_hex_put_word(register8); - UART_direct_msg_put("\r\nREGISTER9:"); - UART_direct_hex_put_word(register9); - UART_direct_msg_put("\r\nREGISTER10:"); - UART_direct_hex_put_word(register10); - UART_direct_msg_put("\r\nREGISTER11:"); - UART_direct_hex_put_word(register11); - UART_direct_msg_put("\r\nREGISTER12:"); - UART_direct_hex_put_word(register12); - UART_direct_msg_put("\r\nREGISTER13:"); - UART_direct_hex_put_word(register13); - UART_direct_msg_put("\r\nREGISTER14:"); - UART_direct_hex_put_word(register14); - //UART_direct_msg_put("\r\nREGISTER15:"); - //UART_hex_put(register15); + + uint32_t registers[NUMBER_OF_REGISTERS] = {}; + char c = '0'; + + UART_direct_msg_put("\r\nARM REGISTERS[R0-R15]:\r\n"); + + for (uint8_t i = 0; i < NUMBER_OF_REGISTERS; i++) + { + /* get register value */ + if (i == 0) + { + registers[i] = getregister0(); + } else + { + registers[i] = getregister(i); + } + + /* start printing */ + UART_direct_msg_put("Register R"); + + /* Print the register number using char c. If we're printing registers 10-15, + we will need to print a leading 1. */ + if (i > 9) + { + UART_put('1'); + } + UART_put(c); + + /* finish printing the message */ + UART_direct_msg_put(": "); + UART_direct_hex_put_word(registers[i]); + UART_direct_msg_put("\r\n"); + + /* increment c to display the next register number. If greater than 9, rollover to 0 */ + c++; + if (c > '9') + { + c = '0'; + } + } + + /* display error count */ + UART_direct_msg_put("\r\nerror count: "); + UART_hex_put(error_count); + UART_direct_msg_put("\r\n\n"); - // Create a command to read a section of Memory and display it - - //int32_t *memory_ptr; /* pointer store the address in memory to display */ + /* Create a command to read a section of Memory and display it */ + uint32_t *memory_ptr = (uint32_t*)MEMORY_STARTING_ADDR; /* create a pointer to reference memory */ + UART_direct_msg_put("Reading data from memory:\r\n"); + for (uint8_t i = 0; i < NUM_ADDR_TO_PRINT; i++) + { + UART_direct_msg_put("Address: "); + UART_direct_hex_put_word((uint32_t)memory_ptr); /* print address */ + UART_direct_msg_put("\tData: "); + UART_direct_hex_put_word(*memory_ptr); /* print data at address */ + UART_direct_msg_put("\r\n"); + memory_ptr++; + } + UART_direct_msg_put("\r\n"); // Create a command to read 16 words from the current stack @@ -455,5 +457,4 @@ UART_msg_put("Mode Error"); } } -} - +} \ No newline at end of file
--- a/UART_poll.cpp Fri Oct 04 21:09:15 2019 +0000 +++ b/UART_poll.cpp Fri Oct 04 22:03:30 2019 +0000 @@ -281,5 +281,17 @@ } } +/******************************************************************************* +* The function UART_direct_hex_put_word puts 1 word in hex directly (no ram buffer) +* to the UART. Used to display full words within registers and memory locations +*******************************************************************************/ +void UART_direct_hex_put_word(uint32_t c) +{ + UART_direct_hex_put((c>>24)); + UART_direct_hex_put((c>>16)); + UART_direct_hex_put((c>>8)); + UART_direct_hex_put((c)); +} +
--- a/frequency_detector.cpp Fri Oct 04 21:09:15 2019 +0000 +++ b/frequency_detector.cpp Fri Oct 04 22:03:30 2019 +0000 @@ -50,6 +50,8 @@ extern UCHAR current_bool_value =1; // trigger for zero detection within the code extern UCHAR last_bool_value = 1; // trigger for zero detection within the code +uint16_t freq_value = 0; + #ifdef __cplusplus }
--- a/main.cpp Fri Oct 04 21:09:15 2019 +0000 +++ b/main.cpp Fri Oct 04 22:03:30 2019 +0000 @@ -48,6 +48,8 @@ extern volatile uint16_t SwTimerIsrCounter; +int os_cb_sections = 0; + Ticker tick; // Creates a timer interrupt using mbed methods Timer main_loop; @@ -70,7 +72,7 @@ gled = !gled; } -//uint16_t temperature; // value that will be external to all variable. stores the value of temperature +uint16_t temperature = 0; // value that will be external to all variable. stores the value of temperature //uint16_t Vtemp; // value in mV of the temperature calculated //uint16_t frequency; // value that will store the frequency detected. Need it to be availaible to all functions //uint16_t flow; // value that will store the flow that is determine
--- a/mbed.bld Fri Oct 04 21:09:15 2019 +0000 +++ b/mbed.bld Fri Oct 04 22:03:30 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file
--- a/shared.h Fri Oct 04 21:09:15 2019 +0000 +++ b/shared.h Fri Oct 04 22:03:30 2019 +0000 @@ -148,42 +148,43 @@ #endif /******************************************************************************* -* All function prototypes are externed in all the modules. +* All function prototypes are visible in all the modules. *******************************************************************************/ -extern void monitor(void); /* located in module monitor.c */ -extern void timer0(void); /* located in module timer0.c */ -extern void serial(void); /* located in module UART_poll.c */ +void monitor(void); /* located in module monitor.c */ +void timer0(void); /* located in module timer0.c */ +void serial(void); /* located in module UART_poll.c */ -extern void UART_put(UCHAR); /* located in module UART_poll.c */ -extern UCHAR UART_get(void); /* located in module UART_poll.c */ -extern UCHAR UART_input(void); /* located in module UART_poll.c */ -extern void UART_direct_msg_put(const char *); +void UART_put(UCHAR); /* located in module UART_poll.c */ +UCHAR UART_get(void); /* located in module UART_poll.c */ +UCHAR UART_input(void); /* located in module UART_poll.c */ +void UART_direct_msg_put(const char *); /* located in module UART_poll.c */ -extern void UART_msg_put(const char *); +void UART_msg_put(const char *); /* located in module UART_poll.c */ -extern void UART_direct_hex_put(UCHAR); /* located in module UART_poll.c */ -extern void UART_direct_put(UCHAR); /* located in module UART_poll.c */ -extern void UART_hex_put(UCHAR); /* located in module UART_poll.c */ -extern void UART_low_nibble_put(UCHAR); /* located in module UART_poll.c */ -extern void UART_high_nibble_put(UCHAR); /* located in module UART_poll.c */ -extern void chk_UART_msg(void); /* located in module monitor.c */ -extern void UART_msg_process(void); /* located in module monitors.c */ -extern void status_report(void); /* located in module monitor.c */ -extern void set_display_mode(void); /* located in module monitor.c */ -extern void UART_direct_hex_put_word(uint32_t); /* located in module monitor.c */ -extern float calculateViscosity(int16_t); /* located in module Calculate_flow.c */ -extern float calculateDensity(int16_t); /* located in module Calculate_flow.c */ -extern float calculateReynoldsNumber(float, float, float); /* located in module Calculate_flow.c */ -extern float calculateStrouhalNumber(float); /* located in module Calculate_flow.c */ -extern float calculateVelocity(uint16_t, float); /* located in module Calculate_flow.c */ -extern float convertVelocityMetersToInches(float); /* located in module Calculate_flow.c */ -extern void calculateFlow(void); /* located in module Calculate_flow.c */ -extern void read_ADC(uint8_t); -extern void frequency_detect(void); -extern void adc_calibration(void); -extern void PwmOutputs_flowmeter(void); -extern void Pulse_Output_Frequency(void); -extern void LCD_Display(void); +void UART_direct_hex_put(UCHAR); /* located in module UART_poll.c */ +void UART_direct_hex_put_word(uint32_t c); +void UART_direct_put(UCHAR); /* located in module UART_poll.c */ +void UART_hex_put(UCHAR); /* located in module UART_poll.c */ +void UART_low_nibble_put(UCHAR); /* located in module UART_poll.c */ +void UART_high_nibble_put(UCHAR); /* located in module UART_poll.c */ +void chk_UART_msg(void); /* located in module monitor.c */ +void UART_msg_process(void); /* located in module monitors.c */ +void status_report(void); /* located in module monitor.c */ +void set_display_mode(void); /* located in module monitor.c */ +void UART_direct_hex_put_word(uint32_t); /* located in module monitor.c */ +float calculateViscosity(int16_t); /* located in module Calculate_flow.c */ +float calculateDensity(int16_t); /* located in module Calculate_flow.c */ +float calculateReynoldsNumber(float, float, float); /* located in module Calculate_flow.c */ +float calculateStrouhalNumber(float); /* located in module Calculate_flow.c */ +float calculateVelocity(uint16_t, float); /* located in module Calculate_flow.c */ +float convertVelocityMetersToInches(float); /* located in module Calculate_flow.c */ +void calculateFlow(void); /* located in module Calculate_flow.c */ +void read_ADC(uint8_t); +void frequency_detect(void); +void adc_calibration(void); +void PwmOutputs_flowmeter(void); +void Pulse_Output_Frequency(void); +void LCD_Display(void); #ifdef __cplusplus }