// XMON 2.1 ALPHA (autoscaling on/off/min/max) 14 feb 2008 // XMON is a free utility for monitoring and communication with MCU development // Made by DZL (help ideas support testing TST) // if this program help you and you are happy to use it, please donate a fee to thomas@webx.dk via paypal // any donation will be put into improving XMON, any size of donation small or big will be most appliciated. // suggestions and bugs to thomas@webx.dk // we will setup a homepage with features and tips and tricks and so on soon, see webx.dk and dzl.dk //------HARDWARE SPECIFIC ROUTINES FIX TO MATCH THE MCU YOU USE ------------------ void init_uart0(void) //AVR Mega serial setup example { UCSR0B = 0x00; //disable while setting baud rate UCSR0A = 0x00; UCSR0C = 0x06; UBRR0L = 25; //25=19200 51=9600 UBRR0H = 0x00; //set baud rate hi UCSR0B = 0x08; // 8 bits UCSR0B = 0xd8; //-Enable rx-complete + receiver + TX complete int + transmitter. } void Sends(unsigned char c) { // this one is for AVR Mega Write character to Serial Port 0 UDR0=c; while(!CHK(UCSR0A,TXC0)); SET(UCSR0A,TXC0); // make ready again } void Sends(int ch) { // this one is for STM32, Write character to Serial Port 1 USART_SendData(USART1, (unsigned char) ch); while (!(USART1->SR & USART_FLAG_TXE)); } //--------------------------------------------------- void plotZero(unsigned int trace) { // value is the plot trace you want to zero on XMON Sends('*'); Sends('T'); Sends(trace); } void plotf(float data,unsigned int trace) // FLOAT values in the PLOT GRAPH { Sends('*'); Sends('d'); Sends(((char*)&data)[3]); Sends('D'); Sends(((char*)&data)[2]); Sends('D'); Sends(((char*)&data)[1]); Sends('D'); Sends(((char*)&data)[0]); Sends('F'); // here is the data handler selector indicator to XMON Sends(trace); } void viewf(float data,unsigned int trace) // FLOAT values in the VIEW variable value area { Sends('*'); Sends('d'); Sends(((char*)&data)[3]); Sends('D'); Sends(((char*)&data)[2]); Sends('D'); Sends(((char*)&data)[1]); Sends('D'); Sends(((char*)&data)[0]); Sends('f');// here is the data handler selector indicator to XMON Sends(trace); } void plotl(long data,unsigned int trace)// LONG 32 bits values in the PLOT GRAPH { Sends('*'); Sends('d'); Sends(((char*)&data)[3]); Sends('D'); Sends(((char*)&data)[2]); Sends('D'); Sends(((char*)&data)[1]); Sends('D'); Sends(((char*)&data)[0]); Sends('I');// here is the data handler selector indicator to XMON Sends(trace); } void viewl(long data,unsigned int trace) // LONG 32 bits values in the VIEW variable value area { Sends('*'); Sends('d'); Sends(((char*)&data)[3]); Sends('D'); Sends(((char*)&data)[2]); Sends('D'); Sends(((char*)&data)[1]); Sends('D'); Sends(((char*)&data)[0]); Sends('i');// here is the data handler selector indicator to XMON Sends(trace); } void plot(unsigned int data,unsigned int trace) // Unsigned Integers 16 bits values in the PLOT GRAPH { Sends('*'); Sends('d'); Sends(data>>8); Sends('D'); Sends(data); Sends('P');// here is the data handler selector indicator to XMON Sends(trace); } void view(unsigned int data,unsigned int line) // Unsigned Integers 16 bits values in the VIEW variable value area { Sends('*'); Sends('d'); Sends(data>>8); Sends('D'); Sends(data); Sends('V');// here is the data handler selector indicator to XMON Sends(line); } void autoscale(char s) // the PLOT GRAPH, in auto mode the min max values will be ignored { Sends('*'); Sends('A'); Sends(s); } #define XMON_AUTO_SCALE_OFF 0 #define XMON_AUTO_SCALE_ON 1 #define XMON_AUTO_SCALE_MIN 254 #define XMON_AUTO_SCALE_MAX 255 #define XMON_RED 0 //Colors of the PLOT GRAPHS #define XMON_GREEN 1 #define XMON_BLUE 2 #define XMON_YELLOW 3 //in your program, example plotZero(XMON_RED); // before use of PLOTS they must be Zeroed in Xmon plotZero(XMON_GREEN);// if this is onlt done once, the display will roll and constantly scale and accumulate values plotZero(XMON_BLUE); // it is also possible to Zero and then plot values again to make real time updating curves view(analog,0); view(analog0min,1); view(analog0max,2); viewl(timer32result,3); plot(what_ever_variabel_int),XMON_RED); plotl(what_ever_variabel_long),XMON_GREEN)); plotf(what_ever_variabel_float),XMON_BLUE)); //set axis min: plotf(-12.54,XMON_AUTO_SCALE_MIN); or: plot(1234,XMON_AUTO_SCALE_MIN); or: plotl(87539,XMON_AUTO_SCALE_MIN); //set axis max: plotf(78.431,XMON_AUTO_SCALE_MAX); or: plot(2474,XMON_AUTO_SCALE_MAX); or: plotl(334325,XMON_AUTO_SCALE_MAX); //Turn auto scaling on/off autoscale(XMON_AUTO_SCALE_OFF); //off, use min max values send autoscale(XMON_AUTO_SCALE_ON); //on default by XMON