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.

strange problem with a PIC18f1320 on a breadboard

Status
Not open for further replies.

nilses

Member level 2
Joined
Aug 22, 2013
Messages
45
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
1,715
Hello,
I have a strange problem with a PIC18f1320 on a breadboard with a led on pin RB4.

The LED blinks happily for 2-3 minutes, then a 2-3 minutes pause and blinking start again.

Is this a configword problem ? Or something else ?
On Pic 16f688 and 16f527 I don't see this feature.

regards,

Nils
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Could be watch dog brown out or your code what language are you using you not really gives us a lot to go on got some code snipett
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

What power source you are using, did you check that?


Best regards,
Peter
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

It may be the connection problem. Or else check your code...
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

It may be the connection problem. Or else check your code...

The circuit is quite simple. Pic18f1320 an a small breadboard,new. Resistor 10k from MCLR to +5v (measured to 4.6volts) with a Fluke DVM.
Resistor 330 ohms between RB4 and led to GND. Micro C pro demo version 6.0, Pikcit programmer.
Simple code comes here:

void main()
{
TRISB = 0 ; // set PORTB as OUTPUT

while (1) // forever
{
PORTB = 0xff ;
Delay_ms(500) ;
PORTB = 0 ;
Delay_ms(500) ;
}
}
In Project Edit I have selected 4.0Mhz internal oscillator. Disabled all execpt MCLR.
Programming the chip goes without error .
Led blinks for approx 2 minutes then a 2 min pause and blinking again. Tried this with 2 chips and 2 Pickit2. The pickit2 is powering the chip.
Installed 100nF cap and 47uF cap between +5 and GND.Wires are ca 7 cm's long.

Tested the same with pic16f688 and pic16f527 with success at first attemp.
The strange thing is that I had the same problem some weeks ago wit pic16f628A, which I gave up and started testing 688 and 527 instead.

Any hints ? Are those PIC's so strange or is it me ? Have used AVR's for 11-12 years without any big problems like this.

regards,

Nils

- - - Updated - - -

It may be the connection problem. Or else check your code...

The circuit is quite simple. Pic18f1320 an a small breadboard,new. Resistor 10k from MCLR to +5v (measured to 4.6volts) with a Fluke DVM.
Resistor 330 ohms between RB4 and led to GND. Micro C pro demo version 6.0, Pikcit programmer.
Simple code comes here:

void main()
{
TRISB = 0 ; // set PORTB as OUTPUT

while (1) // forever
{
PORTB = 0xff ;
Delay_ms(500) ;
PORTB = 0 ;
Delay_ms(500) ;
}
}
In Project Edit I have selected 4.0Mhz internal oscillator. Disabled all execpt MCLR.
Programming the chip goes without error .
Led blinks for approx 2 minutes then a 2 min pause and blinking again. Tried this with 2 chips and 2 Pickit2. The pickit2 is powering the chip.
Installed 100nF cap and 47uF cap between +5 and GND.Wires are ca 7 cm's long.

Tested the same with pic16f688 and pic16f527 with success at first attemp.
The strange thing is that I had the same problem some weeks ago wit pic16f628A, which I gave up and started testing 688 and 527 instead.

Any hints ? Are those PIC's so strange or is it me ? Have used AVR's for 11-12 years without any big problems like this.

regards,

Nils
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Post whole code.

Remove 47uF from uC pins, leave only 100nF between Vdd and Gnd pins close as possible.

Ensure higher voltage then 4,6V for uC, if possible 4,97-5V. PIC18F1320 dont have problem for lower voltages, but keep voltage in 5V range.


Best regards,
Peter
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

I agree with Wizpic, that it is likely to be a be a watchdog problem. Check that this is actually disabled.
Also check your downloader or ICP is not overwriting these flags, I recall much head scratching many years back with my MPLAB ISP ignoring/over ruling my watchdog settings and causing the program to restart after about 20 seconds.
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Probably power source is bad or cheap SMPS adapter. Try with standard 7805 regulator or any other linear/linear LDO for 5V with appropriate usage of capacitors, use 100uF before regulator, 10uF and 100nF after regulator.

Best is to post all project files. Zip all project files and upload.


Best regards,
Peter
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Probably power source is bad or cheap SMPS adapter. Try with standard 7805 regulator or any other linear/linear LDO for 5V with appropriate usage of capacitors, use 100uF before regulator, 10uF and 100nF after regulator.

Best is to post all project files. Zip all project files and upload.


Best regards,
Peter

Hello,

The board is powered by a Pickit2, tried 2 different. Pic16f688 and pic16f527 work fine for many days.
Will post the project files tomorrow evening. At nightshift until 10:UTC in the morning.

regards,

Nils
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Zip and post your mikroC Project files. In Project>Edit Project... is INTRCIO is selected?
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Watchdog timer with maximum prescale is 2.2 minutes. However, it if the watchdog times out the program would restart straight away - it would not take another 2 minutes delay.

Keith
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Hello,

The board is powered by a Pickit2, tried 2 different. Pic16f688 and pic16f527 work fine for many days.
Will post the project files tomorrow evening. At nightshift until 10:UTC in the morning.

regards,

Nils


Try standard power source with earlier suggested regulators. Avoid to supply external boards from PicKit2 power except for programming purposes.


Best regards,
Peter
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Try standard power source with earlier suggested regulators. Avoid to supply external boards from PicKit2 power except for programming purposes.


Best regards,
Peter

Thank you very much for many good tips and hints. I will try them out tomorrow.
I also have to admit that I have not read all the 308 pages in the datasheet, yet.

My oscilloscope will also been taken out from storage and some dust removed ...

regards,
Nils
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Thank you very much for many good tips and hints. I will try them out tomorrow.
I also have to admit that I have not read all the 308 pages in the datasheet, yet.

My oscilloscope will also been taken out from storage and some dust removed ...

regards,
Nils


For sure You declare war to this problem. :)


Best regards,
Peter
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

For sure You declare war to this problem. :)


Best regards,
Peter

Yes, I have been using microprocessors since 1979 and never seen so much trouble in a short time. 5 lines of code and a blinking led and 2 resistors.
I once designed and built a Z80 based printerbuffer with sw in a 2716 EPROM. A total of 80- 90 ic's , 2 sided pcb.
Working the first time it was switched on. In my sparetime if I have some I do some teaching of young children at 12-17 in electronics.
We have built some Velleman kits and moving on to programming PICs because of some sponsored equipment. Personally I would stick to AVR's but money counts here as other places in the public schools. My work is purely volountary in my sparetime and unpaid.

Nils
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Hi nilses,

Mostly check your config register setting ..... I think this is mostly watch dog problem.....as you are ic get reset periodically...

Good luck
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Hi nilses,

Mostly check your config register setting ..... I think this is mostly watch dog problem.....as you are ic get reset periodically...

Good luck

Thanks for the tip. I have disabled /turned off watch dog to simply things and eliminate problems. I don't know, maybe the Project Editor
is displaying wrong values ?
Will check with Pickit2 and compare with datasheet or hardcode manually. Funny pic16f688 and 16f527 works all the time ?

regards,

Nils
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Problem fixed.

Take a look at this code below:

void main()
{
TRISB = 0 ; // set PORTB as OUTPUT
TRISA = 0 ;
PORTA = 0xff ;

while (1) // forever
{
PORTB = 0xff ;
Delay_us(50) ;
PORTB = 0 ;
Delay_us(50) ;
}
}

Delay_ms Changed to Delay_us. Watching the newly dusted oscilloscope now.

I won the war against PIC's, running as expected for almost 2 hours.

Something is still wrong with Delay_ms and Delay_us...

Thank you all guys for all good support and advice.

regards,
Nils
 

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

With Delay_us() the LED will appear as ON all time or OFF all time. The problem is something else and can only be found if you post the project files.

Try this code and post the result.


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
30
31
32
33
//Timer1 Fosc = 4 MHz
//Prescaler 1:8; TMR1 Preload = 3035; Actual Interrupt Time : 500 ms
 
//Place/Copy this part in declaration section
void InitTimer1(){
  T1CON = 0x31;
  TMR1IF_bit = 0;
  TMR1H = 0x0B;
  TMR1L = 0xDB;
  TMR1IE_bit = 1;
  INTCON = 0xC0;
}
 
void Interrupt(){
  if (TMR1IF_bit){
    TMR1IF_bit = 0;
    //Enter your code here
    PORTB = ~PORTB
    TMR1H = 0x0B;
    TMR1L = 0xDB;
  }
}
 
void main(){
 
    TRISB = 0x00;
    PORTB = 0x00;
    ADCON1 = 0x7F;
 
    InitTimer1();
 
    while(1);
}






Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
void main(){
 
    TRISB = 0x00;
    PORTB = 0x00;
    ADCON1 = 0x7F;
 
    while(1){
 
          PORTB = ~PORTB;
          Delay_ms(500);
    }
}

 
Last edited:

Re: PIC18F1320 stops blinking LED and restarts after 2-3 minutes

Hello, thank you for very good help in troubleshooting this issue.
It looks my solderfree breadboard is picking up noise etc. 50 Hz Hum or other noise. Resets of pic etc

When I move my hand over the solderless board I can see the freqeuncy changing.
Tonight DHL came and delerived a PICDEM2PLUS unit to me.
Will try this one out and if this board works I will be happy and go back to the solderinhg irion as soon as possible.

Nils
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top