Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem after connecting reset button to MRCL pin of PIC 18f4550

Status
Not open for further replies.

dido1987

Member level 2
Joined
Apr 1, 2011
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,633
hello ,
am connecting a reset button to my MRCL pin of pic 18f4550 but when i click the button and every thing crash down no more right data on LCD, no more LED blinking!!!!!!!
and those message appear on the ISIS simulation
Code:
[PIC18]PC=0x0000. §MCLR§ is low.Processor is on reset.
[HD44780]Attemped to resd after writing a single nibble
 
Last edited:

john blue

Advanced Member level 3
Joined
Jun 7, 2007
Messages
821
Helped
213
Reputation
430
Reaction score
204
Trophy points
1,323
Activity points
4,749
Re: reset of pic 18f4550

Try on hardware. Sounds like proteus is giving some problems
 

erio

Full Member level 3
Joined
Feb 26, 2008
Messages
176
Helped
27
Reputation
54
Reaction score
23
Trophy points
1,298
Location
Indonesia
Activity points
2,167
Re: reset of pic 18f4550

does MCLR is disabled by accident? check your fuse setting and/or code. make sure the reset pin is enabled (not configured as portE.3)
also try disabling watchdog timer
 

dido1987

Member level 2
Joined
Apr 1, 2011
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,633
Re: reset of pic 18f4550

no a push the button on purpose to check if reset is working or not

and i did configure my watchdog on disable and the pin of MCLR

 
Last edited:

erio

Full Member level 3
Joined
Feb 26, 2008
Messages
176
Helped
27
Reputation
54
Reaction score
23
Trophy points
1,298
Location
Indonesia
Activity points
2,167
Re: reset of pic 18f4550

try to connect VCC using power terminal, do not connect VCC on the USB connector
 

dido1987

Member level 2
Joined
Apr 1, 2011
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,633
Re: reset of pic 18f4550

ok i will try that but am gonna use the usb power in hardware second if it's from USB power LCD will not work and show lines even they are wrong but any way
you see what a mean
 

erio

Full Member level 3
Joined
Feb 26, 2008
Messages
176
Helped
27
Reputation
54
Reaction score
23
Trophy points
1,298
Location
Indonesia
Activity points
2,167
Re: reset of pic 18f4550

its OK if the real hardware is powered from USB as long as it under 500mA.
i noticed that LCD you`re using 4bit interface but left D0 to D3 floating, please connect this to GND
LCD showing black line on powerup? this is the sign of the LCD not initialized properly, please review your code and see if your LCD is initialized properly
 

dido1987

Member level 2
Joined
Apr 1, 2011
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,633
Re: reset of pic 18f4550

i did try what you say but the same problem appear
 

erio

Full Member level 3
Joined
Feb 26, 2008
Messages
176
Helped
27
Reputation
54
Reaction score
23
Trophy points
1,298
Location
Indonesia
Activity points
2,167
very strange problem. Can you make simple program like blinking led? and connect reset pin directly from power terminal without resistor. If same problem still exist,i suggest you reinstall proteus.
 

dido1987

Member level 2
Joined
Apr 1, 2011
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,633
hi,
i take the LCD Librairie and i use the same initialisation of LCD
i wrote a simple code without the USB Librairie and it works
when i push reset the system initialise and every things works
that mean the problem is in the USB code what do you thing ?
 

erio

Full Member level 3
Joined
Feb 26, 2008
Messages
176
Helped
27
Reputation
54
Reaction score
23
Trophy points
1,298
Location
Indonesia
Activity points
2,167
OK, at least we know that your proteus installation is OK..
now you can review your code, maybe you forgot to pet the watchdog, so everytime watchdog kicks in, your processor will be in reset.
 

dido1987

Member level 2
Joined
Apr 1, 2011
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,633
i garantie that watchdog is desabled because i initialize it in my code
there's same thing strange same time reset work's and the hole project but that's rare it's often dosen't work
 

erio

Full Member level 3
Joined
Feb 26, 2008
Messages
176
Helped
27
Reputation
54
Reaction score
23
Trophy points
1,298
Location
Indonesia
Activity points
2,167
do you mind if i take a look of your project?
 

dido1987

Member level 2
Joined
Apr 1, 2011
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,633
the problem is that it's a very long project has dozen of file and the vb.net application and you have to configure the compilator with mplab
but i can show the main.c file
Code:
#include <p18f4550.h>
#include <stdlib.h>
#include "system\typedefs.h"                        // Required
#include "system\usb\usb.h"                         // Required
#include "io_cfg.h"                                 // Required
#include "system\usb\usb_compile_time_validation.h" // Optional
#include "user\user.h"  
#include "C:\Users\Administrateur\Desktop\hid\HID\system\lcd\xlcd_driver.h" 
#include <stdio.h>
#include <string.h>
#include <usart.h>
#define ON 1
#define OFF 0
/** V A R I A B L E S ********************************************************/
#pragma udata

/** P R I V A T E  P R O T O T Y P E S ***************************************/
static void InitializeSystem(void);
void USBTasks(void);

/** V E C T O R  R E M A P P I N G *******************************************/

extern void _startup (void);        // See c018i.c in your C18 compiler dir
#pragma code _RESET_INTERRUPT_VECTOR = 0x000800
void _reset (void)
{
    _asm goto _startup _endasm
}
#pragma code

/** D E C L A R A T I O N S **************************************************/

/******************************************************************************
 * Function:        void main(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Main program entry point.
 *
 * Note:            None
 *****************************************************************************/
void main(void)
{

    InitializeSystem();
       init_lcd();
       LCD_BACKLIGHT=ON;
       lcd_gotoxy(3,0);
       fprintf(_H_USER,"bienvenue");
       lcd_gotoxy(5,1);
       fprintf(_H_USER,"program");
       lcd_gotoxy(0,2);
       fprintf(_H_USER,"_initialisation_"); 
       lcd_gotoxy(0,3);
       fprintf(_H_USER,"___du systeme___");
      // USBTasks();
       while(1)
        {
              ProcessIO(); 
       
                           }//end while
}//end main

 static void InitializeSystem(void)
{
    ADCON1 |= 0x0F;                 // Default all pins to digital      
       mInitializeUSBDriver();         // See usbdrv.h
       UserInit();                     // See user.c & .h
         USBTasks();
}//end InitializeSystem

void USBTasks(void)
{
    /*
     * Servicing Hardware
     */
    USBCheckBusStatus();                    // Must use polling method
    if(UCFGbits.UTEYE!=1)
        USBDriverService();                 // Interrupt or polling method
         
}// end USBTasks

/** EOF main.c ***************************************************************/
and this is the user.c

Code:
#include <p18cxxx.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <usart.h>
#include "C:\Users\Administrateur\Desktop\hid\HID\system\typedefs.h"
#include "C:\Users\Administrateur\Desktop\hid\HID\system\usb\usb.h"
#include "C:\Users\Administrateur\Desktop\hid\HID\io_cfg.h"             // I/O pin mapping
#include "C:\Users\Administrateur\Desktop\hid\HID\user\user.h"
#include "C:\Users\Administrateur\Desktop\hid\HID\system\lcd\picstar_def.h"                 //pour affichage                
#include "C:\Users\Administrateur\Desktop\hid\HID\system\lcd\picstar_delays.h"               //pour l'affichage
//#include "C:\Users\Administrateur\Desktop\hid\HID\system\lcd\xlcd_driver.h" // includes xlcd.h

#define ON 1
#define OFF 0
 
#define DIM 16

/** V A R I A B L E S ********************************************************/
#pragma udata
char Buffer[64];
char var[64]  ;
     /** D E C L A R A T I O N S **************************************************/
#pragma code
void UserInit(void)
{
      LATB=0;
    TRISBbits.TRISB0=0;
    TRISBbits.TRISB1=0;
    TRISBbits.TRISB2=0;
    TRISBbits.TRISB3=0;
    TRISBbits.TRISB4=0;
    TRISBbits.TRISB5=0;
    TRISBbits.TRISB6=0; 
    TRISBbits.TRISB7=0;
}//end UserInit

	 
  void ProcessIO(void)
{  
   int i;
   int nb;
   int lnBuffer ;
char t1[DIM +1];
char t2[DIM +1];
char t3[DIM +1];
char t4[DIM +1];

   u8 counter=0 ;
   u8 LCD_buffer[16];
    USBTasks();
        while(1)   
{   i=0;
    USBTasks();
if (HIDRxReport(Buffer,PacketSize ) > 0) // USB receive buffer has data
 {     
     USBTasks();  
     PORTB=0x02;
     delay_ms(200);
     PORTB=0;
     lcd_delete();
     strcpy(var,Buffer);
     nb=strlen(Buffer); 
for (i=0;i< DIM;i++)
 {
    t1[i]=Buffer[i] ;
    t2[i]=Buffer[DIM +i] ;
    t3[i]=Buffer[2*DIM +i] ;
    t4[i]=Buffer[3*DIM +i];
 }
  t1[DIM ]= '\0';
  t2[DIM ]= '\0';
  t3[DIM ]= '\0';
  t4[DIM ]= '\0';
           switch (var[2])
          {
          case 'm':
            PORTB=0x00; 
           
          break;
          case 'M':
               PORTB=0x80;   
          break;
          case 'c':
                 PORTB=0x40; 
          break; 
          case 'b':
              PORTB=0x20;                                                                                                                                                                                          
          break;
 
           }// fin switch
          lcd_gotoxy(0,0);
                  fprintf(_H_USER,"%s",t1);
                    lcd_gotoxy(0,1);
           fprintf(_H_USER,"%s",t2);
                   lcd_gotoxy(0,2);
          fprintf(_H_USER,"%s",t3);
                   lcd_gotoxy(0,3);
           fprintf(_H_USER,"%s",t4);
           delay_ms(20);
          
  }// end if            
   }//end while

 }//end ProcessIO
				
/** EOF user.c *********************************************************/
 

erio

Full Member level 3
Joined
Feb 26, 2008
Messages
176
Helped
27
Reputation
54
Reaction score
23
Trophy points
1,298
Location
Indonesia
Activity points
2,167
there is nothing wrong with your code. well i`m no expert in C, but pretty well in pascal and basic. but your code looks straightforward so i can understand and nothing wrong. i wonder where the problem is..

anyone who read this thread have an idea to help dido here?
 

dido1987

Member level 2
Joined
Apr 1, 2011
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,633
thanks any way , i apreciate it so much
when i found the solution a will write it here
 

mahm150

Full Member level 1
Joined
Dec 14, 2010
Messages
98
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Cairo, Egypt, Egypt
Activity points
2,001
DEAR
ihave the same problem but without using usb
is you find the solution

---------- Post added at 23:05 ---------- Previous post was at 22:28 ----------

I get the reason connect the mclr pin to vcc
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top