how to check either Controller working or damaged

Discussion in 'Embedded Systems and Microcontrollers' started by ect_09, Oct 28, 2014.

  1. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    Hi,:(
    i want to know that how to check that either Controller working or damaged ,
    am confused because i have PIC 18f452 and its being detect automatically when i want to load HEX file it and at the end it shows message that programming finished successfully, (i attached the image).
    but when i run this on hardware its PORT does not responding..no voltage on its output.
    what should i do..????

    code is here
    Code (Text):
    1. #include<htc.h>
    2.  
    3.  
    4. // PIC 18F452 fuse configuration:
    5. // Config word 1 (Oscillator configuration)
    6. // 40Mhz crystal input
    7. __CONFIG(1, OSCSDIS & HSPLL);
    8. // Config word 2
    9. __CONFIG(2, BORDIS & PWRTDIS & WDTDIS);
    10. // Config word 3
    11. __CONFIG(3, CCP2RC1);
    12. // Config word 4
    13. __CONFIG(4,  LVPDIS & STVREN);
    14. // Config word 5, 6 and 7 (protection configuration)
    15. __CONFIG(5, UNPROTECT);
    16. __CONFIG(6, WRTEN);
    17. __CONFIG(7, TRU);
    18.  
    19. #define _XTAL_FREQ 40000000   //MHz
    20.  
    21. void delay_sec(unsigned char seconds)    // This function provides delay in terms of seconds
    22. {
    23.     unsigned char i,j;
    24.  
    25.     for(i=0;i<seconds;i++)
    26.         for(j=0;j<100;j++)
    27.             __delay_ms(10);
    28. }
    29.  
    30. void main()
    31. {
    32.          
    33.     TRISB = 0;  
    34.  
    35.     while(1)
    36.     {
    37.         PORTB = 0x55;      
    38.         delay_sec(1);   // delay of one second
    39.  
    40.         PORTB = 0xAA;      
    41.         delay_sec(1);    // delay of one second
    42.     }
    43. }
    44.  
    1.png 2.png
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    I am not familiar with this particular part. If I were you I'd pick up a copy of the datasheet, read it very carefully, and establish beyond all doubt:

    What is the default function of each port pin after reset. In some cases they default to a function other than digital input/output. It is quite hard to make an analog input behave as if it were a digital output.
     
  3. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    Try a second chip.
     
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Again, read the section on setting up the oscillator and configuration bits....

    The default configuration bits sets the device up with a RC oscillator. Set it explicitly to HS. Also, the PLL only works in HS oscillator mode and only up to 40MHz - which means you need a 10MHz crystal attached.
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Put the hardware aside and run your code in the MPLAB simulator. See if the simulator agrees the bits are changing.

    If not, hit the data sheet and see what other functions are on those pins; analog capable pins default to analog and must be explicitly set as digital in code.

    If the bits do change, look into how the config bits are being set. Again, MPLAB will tell you what the code did. See if that agrees with your hardware schematic.
     
Loading...