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] PIC18F46K80 Not Working

Status
Not open for further replies.

apsua

Member level 3
Joined
Feb 13, 2015
Messages
62
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
538
Hello,
I am writing a new software with PIC18F46K80, and my prototype board has arrived.
I have programmed the mcu, and placed it to the board, it didnt work. But it is working on Proteus.
Then I have organized the program for PIC18F4620. I placed it, and it worked.
The fuses part of PIC18F46K80 is as below:
Code:
#fuses HSH, NOPUT, BORV27/*BORV30,*/ /*CANB,*/ MCLR, /*NOSTVREN,*/ /*NODEBUG,*/ PROTECT, NOWDT

The fuses part of PIC18F4620 is as below:
Code:
#fuses HS, /*WDT512*/ NOWDT, PROTECT, NOLVP, BORV28/*BORV43*//*NOBROWNOUT*/, PUT

May the problem be about the fuses?
 

There are twelve 8-bit config registers in the 18F46K80 but you are only mentioning 6 bits in total, what are the others set to?

Which compiler are you using?

Brian.
 
  • Like
Reactions: apsua

    apsua

    Points: 2
    Helpful Answer Positive Rating
I am using ccs c compiler. I didnt mention all, others default will be ok, I thought actually.
 

While the config settings are certainly very important, they are not the only source of problems.
However "...it didn't work" is far too general an error statement to be if any use.
Another common source of problems is the 'analog vs digital' settings for some of the pins, but without a better description I have no idea if that even is a possibility here.
Please describe what is working, what isn't (and should be) and preferably show us a small but complete section of code that exhibits the problem.
Also, I gather that you can program the chip but have you tried single stepping through it? If you can't the the oscillator might not be working. If you can, where can you get up to before things go wrong?
Susan
 
  • Like
Reactions: apsua

    apsua

    Points: 2
    Helpful Answer Positive Rating
Hello,
I mean by "working", I mean it is alive, the codes are processing. I am checking only the LCD and one led flashing in 1 seconds.
I don't think analog/digital will be a problem, because I am seeing the LCD pins and the LED's pin is working on Proteus.
About the oscillator, it should be working, because as I say in the first message, when I place PIC18F4620, the program is working, I mean the LCD shows something, the LED flashes. So oscillator shouldn't be the problem source.
If some more code are necessary, I think the part below may only be the other part that can include problem source. Because the other parts, I am not touching while switching between PIC18F46K80 and PIC18F4620.
Code:
//#device WRITE_EEPROM = NOINT
#device WRITE_EEPROM = ASYNC
#define ANALOG_PINS	AN0_TO_AN1
//#device HIGH_INTS = TRUE
#device   ADC = 10                                       // 10 bit a/d okuma
#use delay(clock=20000000, restart_wdt)                  // Osilatör 20 MHz

#define    LCD_PORT_D            1
Code:
void StartUp()
{
	setup_wdt(WDT_2S);
	
	TRISE = 7;
	TRISD = 0;
	TRISC = 0x01;
	TRISB = 0x81;
	PORTA = 0;
	PORTB = 0;
	PORTC = 0;
	PORTD = 0;
	
	LCDInit();
	
	Timer0Init();
	
	InitVariables();
	
	/*setup_adc_ports(ANALOG_PINS);
	setup_adc(ADC_CLOCK_DIV_32);
	set_adc_channel( 0 );*/
	
	return;
}

void Timer0Init()
{
	setup_timer_0(T0_DIV_1);
	set_timer0(40536);
	TMR0ON = 1;
	enable_interrupts(INT_TIMER0);
	enable_interrupts(GLOBAL);
	
	return;
}
 

In your code you set up the WDT and you are enabling interrupts. Are you resetting the WDT in the main code (we are still guessing about a lot of what you do in your code) and are you checking to see if the WDT reset is being triggered?
Also, in changing from one processor to another, are you recompiling the source code with the new processor specified or are you trying to use the same HEX file?
By the way, the fact it is working in the Proteus simulator means very little. The only test of whether code is properly written is when it runs on the hardware. Using a simulator can mean that simulator bugs hide other problems.
Anyway, an output pin can still be driven by the port when it is in analog mode; however it will only ever read '0' on the PORT regardless of the voltage actually on the pin.
Susan
 
  • Like
Reactions: apsua

    apsua

    Points: 2
    Helpful Answer Positive Rating
Hello,
Thanks for your help.
The problem was about missing fuses definitions. The latest state of the fuses line is as below:

Code:
#fuses HSH, NOPUT, NOBROWNOUT, MCLR, PROTECT, NOWDT, NOPLLEN, NOFCMEN, NOIESO, NOPUT, NOSTVREN, NOXINST, NODEBUG, NOCPB, NOCPD, NOWRT, NOWRTB, NOWRTC, NOWRTD
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top