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.

18LF6722 lead me out from the trees please

Status
Not open for further replies.

Zedman

Full Member level 6
Joined
Oct 13, 2003
Messages
331
Helped
9
Reputation
18
Reaction score
6
Trophy points
1,298
Location
Hungary
Activity points
3,511
p18f6722.h

I went into the forest deeply with this chip.

I would like use this chip with an SPI eeprom and a RTC chip and a max232 to attach it to the COM port.
I made the PCB, measured all the GND / Vcc traces made the vias by hand and after that I've put on the 18LF6722 along with a 100nF and a 22uF and a 1k between MCLR and Vcc. I've also put on the 10MHz crystal and 2 18pF caps for the crystal.
I made a simple prog disabled all the peripherals, and set the config according to the osc and disabled everything else. It flashes a LED attached to RE2 with a 330 ohm resistor.
It's running on 3V (2 AA batteries).

The problem: it won't start.

It's a brand new chip.
I tought the caps might not be the correct ones for this crystal, so I've tried 5.6pF 2x5.6pF, 18pF, 22pF, and even 33pF.

After changing the caps few times it's started, but after a few flashes the led turned off.

It's a new PCB I made it because the previous one had the same problem with a 18F6520.

It might be a lame config issue, or a huge bug i cannot see but please show me the right way.

:cry:

thanks
 

bbsiz

Iam at work now, I'll post them later today.

The funny is that I made lots of projects with this type of 10MHz crystal and 18pF caps and other PICs (16Fxxx and even 18F8620).
I've connected all the GND and Vcc lines correctly Avss and Avdd too.

Once I've ran into an issue that LVP was enabled originally and it couldn't be started until I pulled the RB5/PGM pin down to GND. But now it didn't help.

thanks
 

So here is the schematic.

No LVP is not enabled, and I have 100nF and 10uF for decoupling, but only 1-1 pieces. They may not enough.

I've tried to switch on the internal 4MHz osc with PLL, it works.

Does the factory calibrated internal osc reliable at least as the external crystal or it's worst?
 

we see no pcb layout and no code... how can we tell what's wrong when we see only 1/3 of the whole device...

if it works correct on the internal, i think that there is some noise on your board somewhere... you should decouple EVERY Vdd pin with a 100nF cap. also you should have the tracks to crystal as short as possible. and you should avoid putting some noisy stuff around it like power supply, some digital IC which maka a lot of influences...

also - sometimes a serial or parallel resistance is required for the crystal.

BTW your schematic is really NOT a clear one. try using more labels. not PORTs, but NET LABELs - they are smaller. PORTs are required only for multi sheet schematics.

0x41 0x56 0x45!!
 

Add to that your 100K pullups are way to high for most I2C communication, try 4.7K or 10K tops.
Your 4.7K resistor should be increased to 10K to 22K for reliable ICD operation.
You can also ignore R2 as it's done internally on the 25LC1024
Also are you turning off the WDT?
 

Sorry about the schematics, it's made for myself, that's why not so clear I haven't spent too much time to make it nicer.

I know there are values to fix, they aren't the right ones yet, I've just dropped them in since its a prototype. I'll fix them, altough they do do much with the start of the PIC.
The datasheet says MCLR needs 1-10k so I draw 4.7k.

The PCB also not a nice one, I let Pr*tel draw it, and then i fixed some to make it easier to photo.

Here is the code:

(delay.h is the original from hi-tech)

Code:
#include <p18f6722.h>
#include "delay.h"

#pragma config OSC = HSPLL
#pragma config FCMEN = OFF
#pragma config IESO = OFF
#pragma config PWRT = ON
#pragma config BOREN = OFF
#pragma config BORV = 3
#pragma config WDT = OFF
#pragma config MCLRE = ON
#pragma config LPT1OSC = OFF
#pragma config CCP2MX = PORTE
#pragma config STVREN = OFF
#pragma config LVP = OFF
#pragma config BBSIZ = BB2K
#pragma config XINST = OFF
#pragma config DEBUG = OFF
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF, CP4 = OFF, CP5 = OFF, CP6 = OFF, CP7 = OFF, CPB = OFF, CPD = OFF
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF, WRT4 = OFF, WRT5 = OFF, WRT6 = OFF, WRT7 = OFF, WRTB = OFF, WRTC = OFF, WRTD = OFF
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF, EBTR4 = OFF, EBTR5 = OFF, EBTR6 = OFF, EBTR7 = OFF, EBTRB = OFF

#define LED       PORTEbits.RE2


void Init(void)
{
  TRISA=0b00001111; // SCL SDA INTRA INTRB
  TRISB=0b00000000; // 
  TRISC=0b10010000; // SDO, RX
  TRISD=0b00000000; // 
  TRISE=0b00000000; // 
  TRISF=0b00000000; // 
  TRISG=0b00000100; // 

  CCP1CON=0;    // Disable capture/compare module
  CCP2CON=0;    // Disable capture/compare module
  CCP3CON=0;    // Disable capture/compare module
  CCP4CON=0;    // Disable capture/compare module
  CCP5CON=0;    // Disable capture/compare module

  SSP1CON1=0;    // Disable MSSP 
  SSP2CON1=0;    // Disable MSSP 2

  ADCON0=0b00000000;
  ADCON1=0b00001111;
  ADCON2=0b00001111;

  CMCON=0b00000111;
  CVRCON=0b00000000;

  HLVDCON=0b00000000;
}

void main(void)
{

  Init();

  while(1)
  {
    LED=1; 
    DelayMs(250); DelayMs(250); 

    PORTEbits.RE1=0;
    LED=0;
    DelayMs(250); DelayMs(250); 
  }
}
 

looks quite ok to me... aren't all those things you disable on startup default disabled on POR? if yes, then you may skip that part.

you may want to change the blinking functions to somethin using XOR, this way it will be half the size.

Code:
  while(1) 
  { 
    LED^=1; 
    DelayMs(250); DelayMs(250); 
  }

i assume that there is an XOR operator (^=) in your compiler, if not, you can check the manual to find a way to XOR some bits [;

anyway - you say, that is DOES work with internal oscillator flawlessly, and on external crystal if works for a while and then dies?

0x41 0x56 0x45!!
 

Thanks for the suggestions on the code, I disabled everything in the Init func again just to make sure.

Exactly as you said if it starts than it runs for a couple of secs, than freezes.
I've tried the Two way start option (it's a config setting) it starts from the int osc and then switches over to the external if it gets stable enough, but it NEVER switches...

I got a hint on the mchip forum that I should try to switch back to mplab 7.5 currently I am using 8.0. I'll try.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top