PDA

View Full Version : Convert from 16f877a to 18f458



svein97
- 30th November 2005, 17:53
I have reached the memorylimit, and wants to convert the program to a 458-device.
I have selected the 18f458 in Microcodestudio, and compiled.
In MPLAB I select the config. bits and set osc to HS( Like I did for 877a).
The oscillator does not start, and the device is not working at all.

Hints?

Ron Marcus
- 30th November 2005, 20:12
I have reached the memorylimit, and wants to convert the program to a 458-device.
I have selected the 18f458 in Microcodestudio, and compiled.
In MPLAB I select the config. bits and set osc to HS( Like I did for 877a).
The oscillator does not start, and the device is not working at all.

Hints?

I've used the 452 for quite some time now.I have had no issues. Are you using a crystal or resonator? Have you tried a simple loop program to flash a LED or make a sound? There are different registers to config at start up, and there could be a number of mechanical reasons it doesn't work either. Have you tried substituting the processor with a spare?

Ron

svein97
- 30th November 2005, 20:41
I've used the 452 for quite some time now.I have had no issues. Are you using a crystal or resonator? Have you tried a simple loop program to flash a LED or make a sound? There are different registers to config at start up, and there could be a number of mechanical reasons it doesn't work either. Have you tried substituting the processor with a spare?

Ron
Same prog.Same osc. (20 mc crystal). Spares is the same...
That is... the same circuit, same program. The 877a works fine.

Dave
- 30th November 2005, 21:10
svein97, I have also changed from 16F877 to 18F452 without any problems. Down load the data sheet and make sure the oscillator settings are correct and the RA6 pin is set correctly. It can be used as an I/O line with this processor unlike the 16F877. Also make sure the oscillator switch is disabled as it can be changed within the operating software. Attached is one of the configuration sequences I use. Look at the registers I set and read the data sheet to see if they affect the way you configure your old code for the 16F877.

OSCCON = 0 'SET SYSTEM CLOCK SWITCH BIT
RCON = %00011111 'CLEAR IPEN,RI,TO,PD,POR,BOR
INTCON2 = %11000000 'NO PULL-UPS,INTEDG0 RISING,INTEDG1,INTEDG2,TMR01P,RBIP
INTCON3 = %00000000 'CLEAR INT2IP,INT1IP,INT2IE,INT1IE,INT2IF,INT1IF
' PIE1 = %00100000 'CLEAR ALL INTERRUPT ENABLE BITS(EXCEPT RCIE)
PIE2 = %00000000 'CLEAR ALL INTERRUPT ENABLE BITS
IPR1 = %00000000 'SET ALL INTERRUPT PRIORITY BITS TO LOW
IPR2 = %00000000 'SET ALL INTERRUPT PRIORITY BITS TO LOW
PIR1 = %00000000 'CLEAR ALL INTERRUPT FLAGS
PIR2 = %00000000 'CLEAR ALL INTERRUPT FLAGS
ADCON0 = %10000001 'FOSC/64,AN0,A/DONE,A/D OFF
ADCON1 = %11000010 'RIGHT JUST,A/D CLOCK SELECT,RA0:RA3,RA5 ANALOG PINS, RE0:RE2 DIGITAL PINS
LVDCON = %00001111 'CLEAR IRVST,LVDEN,AND SELECT LVDIN
WDTCON = %00000000 'DISABLE WATCH DOG TIMER

TRISA = %101111 'INITIALIZE PORT DIRECTIONS
TRISB = %01101111
TRISC = %10101001
TRISD = %00000011
TRISE = %00000111

T0CON = %00000000 'PRESCALER,WRITE PRESCALER 1/2, TURN OFF TIMER 0
' T1CON = %10000100 'WRITE PRESCALER 1/1, TURN OFF TIMER 1
T2CON = %00000100 'WRITE PRESCALER 1/1, TURN ON TIMER 2
T3CON = %10000100 'WRITE PRESCALER 1/1, TURN OFF TIMER 3
TMR2 = 0 'CLEAR TMR2 MODULE REGISTER
PR2 = $FF 'SET PERIOD (1/1 PRESCALE * 256 PR2 * 1/40,000,000 * 4 = 39.06 Khz.
CCPR1L = $00 'CLEAR UPPER 8 BITS
CCPR2L = $00 'CLEAR UPPER 8 BITS
CCP1CON = $0C 'PLACE CCP1 INTO PWM MODE
CCP2CON = $0C 'PLACE CCP2 INTO PWM MODE


Dave Purola,
N8NTA

svein97
- 30th November 2005, 21:52
Tried to load with the same... wont work! The PIC doesn't start!!!!! Not at all!!
Uses the MPLAB, Osc= HS, osc.sw=disble,pwrup timer=dis,brown....enable 2,4v...WDT enable...wdtPs=128 StackOF=En.

Dave
- 1st December 2005, 11:37
svein97, Are you using a crystal or a resonator? I only use resonators as they are cheaper and have had no problems with them in the last 10 years even at high baud rates. I wonder about your choice of caps to ground at the crystal. They should be no more than about 12pF and should be as close to the VSS pin as possible. I did notice that you are enabling the watchdog timer option. Are you using it within your code? Also I use a 10k resistor to VDD thru a 1N4148 to the RESET/VPP pin on the PIC for the reset circuit as I have provisions for ICSP on my boards. If you have access to an oscilloscope with a 1pF 10x probe look at the OSCout pin and see if it is in oscillation after power is applied. Also make sure that BOTH VSS pins are tied to ground of your supply. LOL

Dave Purola,
N8NTA