Need help in vb<>pic16F877a<> LCD

Thread Starter

sgkho

Joined Feb 2, 2012
11
We have tried plenty of way but cant solve the problem hope can get expert help in solving the problem cos it almost near the submission date.

The logic is as below :
there are two ways that user is able to control the home security mode either by pressing Character A,B,C,D in keypad or vb send char A,B,C,D to activate certain security mode but the problem is neither vb sending char A nor keypad A clicked works. Which the LCD should be display the "A " mode (away mode). Our program are able to display the status of the sensors in vb interface but user not able to control the mode . :confused:

I have attach the main program n my usart.c code . Hope to get reply soon, thx.
 

Attachments

ErnieM

Joined Apr 24, 2011
8,153
zip is corrupted. Try posting a short segment of the code where problem is directly using code tags.

Do not post if you do not understand what I just said.
 

spinnaker

Joined Oct 29, 2009
7,835
There are 3 main things that cause problems with LCD assuming the code is mainly correct.

1. The contrast pin is not wired correctly. Use a 10K pot and adjust.

2. It is wired wrong. Step through your code and verify with a scope or logic probe that pins are changing on the LCD as you expect.

3. The delays after various commands is incorrect. You might find some code that works fine on another MCU but that does not mean it will work on yours if they are different clock speeds.
 

Thread Starter

sgkho

Joined Feb 2, 2012
11
zip is corrupted. Try posting a short segment of the code where problem is directly using code tags.

Do not post if you do not understand what I just said.
the coding quite alot so i reupload it . The prob is how to put my gui_control() to the lcd function so that in either case both works and can control the sensors n display the status at LCD


There are 3 main things that cause problems with LCD assuming the code is mainly correct.

1. The contrast pin is not wired correctly. Use a 10K pot and adjust.

2. It is wired wrong. Step through your code and verify with a scope or logic probe that pins are changing on the LCD as you expect.

3. The delays after various commands is incorrect. You might find some code that works fine on another MCU but that does not mean it will work on yours if they are different clock speeds.
for pins assignment or circuit i dont think it will have problem since i previously able to use keypad control but when added in vb control command then only keypad control and vb control nt working.
 

Attachments

Thread Starter

sgkho

Joined Feb 2, 2012
11
pls , i really need help , If dont work my GUI part just partially complete.
I have tried out with timer interrupt to let the main program jump out of the while loop when there is no data transfer in usart n a flag to assign if gui is selected the keypad option will be disable. But it still facing same problem. Hope can get help. Really appreciate it,thanks...:(
 

Attachments

spinnaker

Joined Oct 29, 2009
7,835
You said you "think" the connections are correct. Thinking is not knowing. Have you confirmed with a scope, logic probe, logic analyzer etc. the inputs on the LCD are changing how you expect them to change?

Most people do not want to open a zip file. You never know what it contains. Even if someone wants to open it, they are not going to read through hundreds of lines of code to troubleshoot your problem.

If you are have problems with the LCD then create a small program to simply display Hello on the LCD.

You need to make some attempt to help yourself if you expect others to help you.
 

Thread Starter

sgkho

Joined Feb 2, 2012
11
You said you "think" the connections are correct. Thinking is not knowing. Have you confirmed with a scope, logic probe, logic analyzer etc. the inputs on the LCD are changing how you expect them to change?

Most people do not want to open a zip file. You never know what it contains. Even if someone wants to open it, they are not going to read through hundreds of lines of code to troubleshoot your problem.

If you are have problems with the LCD then create a small program to simply display Hello on the LCD.

You need to make some attempt to help yourself if you expect others to help you.
sry for my improper language and the way seeking for help. LCD part i'm is my partner doing . Previously without adding the gui control part,the keypad functioned well that able to allow user to select the security mode and display the status on LCD . So dont the LCD functioned correctly not the problem of pins and LCD program ?

The problem arise when it come to integrate both gui and keypad together. Both GUI control and Keypad control does not work which the keypad suppose functioning as previously but when user key input mode,the LCD still in the main display words that require user to select the security mode.

The problem is due to the system unable to jump out of the gui_control in while(1) main program as in usart, it will continue looping until there is a char/data receive then only it will jump out of the gui_control function so we added in usart interrupt which the interrupt suppose to be functioning but it not. So just do it part by part, is that correct the way i use to interrupt my usart ?

This is the interrupt declaration and program:
Rich (BB code):
int counter = 0;

static void interrupt isr(void)
{
        
    
    if(TMR0IE && TMR0IF)
        {        
          TMR0IF=0;  //clear flag

            if (counter > 60)
            {
                CREN=0;
                counter = 0;
                TMR0IE = 0;     
            }
            counter++;  //increment over flow counter
        }

    
}
Gui part
Rich (BB code):
void gui_control(void)
{

    TMR0IE = 1;  //Enable TIMER0 Interrrupt
    counter = 0;
    switch(USARTReadByte())
    {
    case 'A': if (away==1);
              break;
    case 'B': if (home=1);
              break;
    case 'C': temperature();
              delayS(3);
                digital_reset=1;
              break;
    case'D':  if (pir=1);
              break;
    default:
              break;
    }
    
    TMR0IE = 0;
}
    }
}
Main program (interrupt configuration)
Rich (BB code):
    // TMR 0 configuation
    T0CS = 0;       //Prescaler gets clock from FCPU (5MHz)                
    PSA = 0;       //Timer clock source is from prescale                
    PS2 = 1;       //prescale 1:256
    PS1 = 1;       //set to "111"
    PS0 = 1;       //prescaler rate bits
    RCIE = 0;      //USART receive interrupt disable bit
    GIE = 1;       //Enable INTs globally
    PEIE = 1;      //Enable Peripheral Interrupt
    TMR0IE = 0;    //Enable TIMER0 Interrupt
 
Last edited:

spinnaker

Joined Oct 29, 2009
7,835
You are setting TMR0IE to zero. Every Pic I have ever seen it needs to be a 1.

Check your data sheet.

There is no need for

if(TMR0IE && TMR0IF) in your ISR

if(TMR0IF) will do

you need to clear TMR0IF in your ISR

TMR0IF = 0;

That is just the beginning. I strongly suggest you read up on interrupts. Also you should create a small program just for Timer 0 interrupt to learn how it works.
 

Thread Starter

sgkho

Joined Feb 2, 2012
11
You are setting TMR0IE to zero. Every Pic I have ever seen it needs to be a 1.

Check your data sheet.

There is no need for

if(TMR0IE && TMR0IF) in your ISR

if(TMR0IF) will do

you need to clear TMR0IF in your ISR

TMR0IF = 0;

That is just the beginning. I strongly suggest you read up on interrupts. Also you should create a small program just for Timer 0 interrupt to learn how it works.
oic , thanks for pointing up the problem. I will study up some tutorial for interrupts.

why are you saving RAR files with ZIP extension?
this is the reason your attachments appear corrupt...
oic , thanks for the info cos i'm using rar so dont knw it will be occur error if change to zip
 
Top