Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

[SOLVED] my pic18F4520 is not responding for any thing

Status
Not open for further replies.

srjth.m1

Full Member level 3
Joined
Aug 6, 2012
Messages
157
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Location
India
Activity points
2,126
my pic18F4520 is not responding for any thing when am touching in RA6 pin some pin`s of some ports will get activated(tested with LED)
-4mhz XT oscillator..pls reply fast somebody....
 

Hi,

You do not really tell us anything about your set up.

You need to show your circuit and program code.

Are you using a breadboard ?

Why are you using a 4mhz Xt oscillator whn you have an internal 4 mhz one ?
 

i just want to activate the port and just to blink the LED ,How to activate internal oscillator iam using Micro C pro v-5.6.1

- - - Updated - - -

i just want to activate the port and just to blink the LED ,How to activate internal oscillator iam using Micro C pro v-5.6.1

i mean XT-4mhz is an internal oscillator am nt using any external oscillator,am doing in breadboard only
 
Last edited:

You should first show us the schematic of your arrangement and the code. You should also ensure that all connections are proper (no loose connections).
 

Untitled.png

itz just an example i have changed the mcu and coding.......
 

Hi,

Your circuit looks good, apart from the Mclr line.

What does your Config line say for MCRL = ON or OFF ?

If it is ON then it needs to be MCLR pulled up with 10k, or if you programmer is still connected you can, depending on programmer type, release it from program mode back to +5v high.

Also post you code incase you have a problem there - its easy to get things wrong when you first try to get going.
 

MCLR is ON and i hav connected it to a 5v through 10k....,and i have now tried with many programs..


mclr-on
oscillatr=XT 4Mhz
all others disabled..
this program is simply blinks the led connected to RB7


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
void main()
{
 TRISB=0;
 
 while(1)
  {
    PORTB.RB7=1;
    delay_ms(500);
     PORTB.RB7=0;
     delay_ms(500);
  
}
}



itz also not working........!8-O...my ports not activating when am touching the RA6 pin some ports getting activated!!

- - - Updated - - -

Thanks all,.....!my problem was in config i have changed oscillator to internal and RA6,RA7 to port function
 
Last edited by a moderator:

Hi,

Good that you have got it running, think you ought to set the other Config parameters to ensure it works ok.

Here is what I use. ( assemly code show)
CONFIG OSC=INTIO67, PWRT=ON, BOREN=OFF, WDT=OFF, MCLRE=ON, LPT1OSC=OFF, PBADEN=OFF
CONFIG LVP=OFF, XINST=OFF, DEBUG=OFF, WDTPS=32768

The config tells the chip that you want to use its Internal oscillator, but you also need to use the OSCCON instruction to set the speed you want otherwise it defaults to 1Mhz.
 
Thank u verymuch wp100... how can i set OSCCON for internal oscillator??
 

Check this file. It is using Int OSC 4 MHz.

-------------Update-----------------

I think you can use OSCCON = 0b01101111;
 

Attachments

  • led_blink.jpg
    led_blink.jpg
    185.6 KB · Views: 66
  • led_blink.rar
    36.4 KB · Views: 46
Last edited:
Now i want to take input from port A when i am giving a high input the corresponding out put LED should glow so i have written the following pgrm but itz not getting


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void main()
{
   TRISA=1;
   TRIS B=0;
  OSCCON = 0b01101111;
while(1)
{
 if(PORTA.RA1==1)// if RA1 is  high then RB7 should glow
{
 PORTB.RB7=1;
}
else
{
PORTB.RB7=0;
}
}
}

 
Last edited by a moderator:

Try this code.

Code:
void main() {
       TRISA = 0x02;
       TRISB = 0x00;
       PORTB = 0x00;
       ADCON1 = 0b00001111;
       CMCON = 0x07;
       
       while(1) {
               if(PORTA.F1 == 1) {
                      Delay_ms(30);
                      if(PORTA.F1 == 1) {
                           PORTB.F7 = 1;
                      }
                      else {
                           PORTB.F7 = 0;
                      }

               }
       }
}

You have set TRISA = 1; It should be 0x02; You are using RA1 so it is 00000010 which is 0x02.
 

Attachments

  • led_switch.rar
    50.4 KB · Views: 42
  • led_switch.jpg
    led_switch.jpg
    166.4 KB · Views: 66
  • led_switch.rar
    50.9 KB · Views: 43

THANK U internetuser2k12 ...I have to check it....!
 

i have done the connections,and the LED is blinking becz of the delay what should do?
 
Last edited:

That happens if you do not do debounce. If you press and hold the button the led turns on, if you release the button the led turns off.
 

actually i want to connect 6 led similarly now what happens is when am giving a high to A port it gives output forRB7 only
 
Last edited:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
void main() {
       TRISA = 0x02;
       TRISB = 0x00;
       PORTB = 0x00;
       ADCON1 = 0b00001111;
       CMCON = 0x07;
       OSCCON=0B01101111;
 
       while(1) {
               if(PORTA.F1 == 1) {
                      Delay_ms(10);
                      if(PORTA.F1 == 1) {
                           PORTB.F7 = 1;
                    }
                    } 
               
              else  if(PORTA.F2==1){
               Delay_ms(10);
               if(PORTA.F2==1){
               PORTB.F6=1;
 
               }
               else
               {
                PORTB=0;
                }
              }
       }
}





Similarly..6 led's..when each switch ON corresponding led should glow..!
 
Last edited by a moderator:

Here is the code

Code:
void main() {
       TRISA = 0b01111111;
       TRISB = 0b00000000;
       PORTB = 0b00000000;
       ADCON1 = 0b00001111;
       CMCON = 0b00000111;

       while(1) {
               if(PORTA.F0 == 1) {
                      Delay_ms(30);
                      if(PORTA.F0 == 1) {
                           PORTB.F0 = 1;
                      }

               }
               
               if(PORTA.F1 == 1) {
                      Delay_ms(30);
                      if(PORTA.F1 == 1) {
                           PORTB.F1 = 1;
                      }

               }
               
               if(PORTA.F2 == 1) {
                      Delay_ms(30);
                      if(PORTA.F2 == 1) {
                           PORTB.F2 = 1;
                      }

               }
               
               if(PORTA.F3 == 1) {
                      Delay_ms(30);
                      if(PORTA.F3 == 1) {
                           PORTB.F3 = 1;
                      }

               }
               
               if(PORTA.F4 == 1) {
                      Delay_ms(30);
                      if(PORTA.F4 == 1) {
                           PORTB.F4 = 1;
                      }

               }
               
               if(PORTA.F5 == 1) {
                      Delay_ms(30);
                      if(PORTA.F5 == 1) {
                           PORTB.F5 = 1;
                      }

               }
               
               if(PORTA.F6 == 1) {
                      Delay_ms(30);
                      if(PORTA.F6 == 1) {
                           PORTB.F0 = 0;
                           PORTB.F1 = 0;
                           PORTB.F2 = 0;
                           PORTB.F3 = 0;
                           PORTB.F4 = 0;
                           PORTB.F5 = 0;
                      }

               }
       }
}
 

Attachments

  • 6_led.jpg
    6_led.jpg
    164.4 KB · Views: 51
  • 6_led.rar
    55.3 KB · Views: 41

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top