betuse
Junior Member level 3
Hi collegues,
I use EasyMx for Stellaris with ARM C4 mcu, mikroc pro for arm,
I measure RPM on DC motor with encoder, and show on TFT every 1 sec,
everithing is Ok, but I can not show clear RPM number on TFT because new numbers shows over previous numbers...
after a short time I see only some smeared color...
I think I am clear with explanation,
can somebody advice how to "refresh" new number of RPM with clear previous number?
the code is
I use interrupt for 100ms, and count encoder pin,
and calculate RPM with encoder holes number....
if somebody have solution please share with me,
best regards
I use EasyMx for Stellaris with ARM C4 mcu, mikroc pro for arm,
I measure RPM on DC motor with encoder, and show on TFT every 1 sec,
everithing is Ok, but I can not show clear RPM number on TFT because new numbers shows over previous numbers...
after a short time I see only some smeared color...
I think I am clear with explanation,
can somebody advice how to "refresh" new number of RPM with clear previous number?
the code is
Code:
#include "Resources.h"
sbit ENCODER at GPIO_PORTG_DATA.B4;
sbit ENCODER_Direction at GPIO_PORTG_DIR4_bit;
unsigned int RPM, Cnt = 0;
unsigned char Txt[4];
unsigned char DsplyCnt = 0;
// TFT module connections
char TFT_DataPort at GPIO_PORTJ_DATA;
sbit TFT_RST at GPIO_PORTH_DATA5_bit;
sbit TFT_RS at GPIO_PORTG_DATA7_bit;
sbit TFT_CS at GPIO_PORTH_DATA6_bit;
sbit TFT_RD at GPIO_PORTC_DATA5_bit;
sbit TFT_WR at GPIO_PORTH_DATA4_bit;
sbit TFT_BLED at GPIO_PORTA_DATA3_bit;
char TFT_DataPort_Direction at GPIO_PORTJ_DIR;
sbit TFT_RST_Direction at GPIO_PORTH_DIR5_bit;
sbit TFT_RS_Direction at GPIO_PORTG_DIR7_bit;
sbit TFT_CS_Direction at GPIO_PORTH_DIR6_bit;
sbit TFT_RD_Direction at GPIO_PORTC_DIR5_bit;
sbit TFT_WR_Direction at GPIO_PORTH_DIR4_bit;
sbit TFT_BLED_Direction at GPIO_PORTA_DIR3_bit;
// End TFT module connections
void DrawScr() {
TFT_Init_ILI9341_8bit(320, 240);
TFT_Fill_Screen(CL_WHITE);
TFT_Set_Pen(CL_Black, 2);
TFT_Line(20, 205, 300, 205);
TFT_Line(20, 40, 300, 40);
TFT_Set_Font(&HandelGothic_BT21x22_Regular, CL_RED, FO_HORIZONTAL);
TFT_Write_Text("DC Motor with LMD18200", 40, 14);
TFT_Set_Font(&HandelGothic_BT21x22_Regular, CL_RED, FO_HORIZONTAL);
TFT_Write_Text("Tiva C", 19, 210);
TFT_Set_Font(&HandelGothic_BT21x22_Regular, CL_RED, FO_HORIZONTAL);
TFT_Write_Text("TI", 220, 210);
TFT_Set_Font(&HandelGothic_BT21x22_Regular, CL_Black, FO_HORIZONTAL);
TFT_Write_Text("Speed (RPM): ", 90, 50);
TFT_Set_Font(&HandelGothic_BT21x22_Regular, CL_Black, FO_HORIZONTAL);
TFT_Write_Text("Direction (CW / CCW): ", 60, 120);
}
void Timer0A_interrupt() iv IVT_INT_TIMER0A_16_32_bit {
TIMER_ICR_TATOCINT_bit = 1;
RPM = 6*Cnt; // Speed in RPM
IntToStr(RPM, Txt); // Convert to string
Cnt = 0;
DsplyCnt++;
if(DsplyCnt == 10) { // 1 s ?
DsplyCnt = 0;
TFT_Set_Font(&HandelGothic_BT21x22_Regular, CL_Red, FO_HORIZONTAL);
TFT_Write_Text(Txt, 125, 80);
}
}
void main(){
GPIO_Digital_Input(&GPIO_PORTG, _GPIO_PINMASK_4);
GPIO_Digital_Output(&GPIO_PORTF, _GPIO_PINMASK_4); // Enable digital output on PORTF, bit4 za PWM
GPIO_PORTF_DATA.B4 = 1; //PWM pinot od LMD, vrti
TFT_Set_Default_Mode();
DrawScr();
SYSCTL_RCGC1_TIMER0_bit = 1; // Enable clock gating for timer module 0
EnableInterrupts(); // Enables the processor interrupt.
TIMER_CTL_TAEN_bit = 0; // Disable timer
TIMER0_CFG = 0; // Set 32-bit timer configuration
TIMER0_TAMR |= 2; // Set periodic mode
TIMER0_TAILR = Get_Fosc_kHz()*100; // Set interval load
NVIC_IntEnable(IVT_INT_TIMER0A_16_32_bit); // Enable timer interrupt
TIMER_IMR_TATOIM_bit = 1; // Enable time-out timer A interrupt
TIMER_CTL_TAEN_bit = 1; // Enable timer A
while(1){
while(ENCODER == 0); // Wait if 0
Cnt++; // Increment encoder count
while(ENCODER == 1); // Wait if 1
}
}
I use interrupt for 100ms, and count encoder pin,
and calculate RPM with encoder holes number....
if somebody have solution please share with me,
best regards