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.

Understanding Fosc (PIC18F4620)

Status
Not open for further replies.
The COM Port works fine when others try to use it on my laptop(with their board and my Serial US Adaptor). I have a feeling my board is messed up or something! Any Serial port troubleshooting tips?
 

Here is a loopback test procedure:



The PICDEM 2 Plus is a relatively simple board, so there are not many components to fail.

BigDog

---------- Post added at 00:19 ---------- Previous post was at 00:16 ----------

Here is another loopback test:

**broken link removed**

Have you tried powering down the PICDEM2 Plus, establishing the serial connection via a terminal emulator and then powering the PICDEM2 Plus back up?

BigDog
 
Have you tried powering down the PICDEM2 Plus, establishing the serial connection via a terminal emulator and then powering the PICDEM2 Plus back up?BigDog

Yup I just tried this , nothing comes up on the screen. The adaptor is working fine.

I just checked the voltage on the J1 ( serial port). Pin 2 (Tx) = 6.09 V and Pin 3(Rx) =0.1V . Does this seem right to you?
I tried using "Real term" and once it gave me an error "Break" suggesting that RXD line is broken. It relates to the V on Rx pin being 0.1 V . What V should be on Rx?


(By V I mean Volatge)

PS: Today I feel more like a Detective than an engineer, putting all my energy to find the root cause of this problem! :roll::lol:

---------- Post added at 14:37 ---------- Previous post was at 13:29 ----------

I measured the Voltage across relevant pins and here are the voltages :

Please let me know if you see anything unusual :

 
Last edited:

The simplest way to test your USB to RS-232 Serial Adapter is to short pins 2 and 3 together of the DB9. Examine the base of the pins in the DB9 for the correct pin numbers. Then using a terminal emulator like Hyperterminal open a connection to the appropriate COM port at any BAUD rate with NO hardware flow control. Any characters typed into the terminal emulator should loopback and appear in the terminal screen.

BigDog
 
Yup i performed a loopback test and the adaptor passed the test very well! The adaptor works fine! Its my board's RXD thats broken!
 

Test the MAXIM RS-232 transceiver chip on your PICDEM 2 PLUS by pulling the PIC18F4620 from the board and shorting the appropriate TX and RX pins of the DIP Socket, then perform the same loopback test from your PC.

BigDog

---------- Post added at 03:53 ---------- Previous post was at 03:49 ----------

I believe you'll need to jumper pins 25 and 26 on the 40-pin socket, to successfully create a loopback.
 
Test the MAXIM RS-232 transceiver chip on your PICDEM 2 PLUS by pulling the PIC18F4620 from the board and shorting the appropriate TX and RX pins of the DIP Socket, then perform the same loopback test from your PC.

BigDog

---------- Post added at 03:53 ---------- Previous post was at 03:49 ----------

I believe you'll need to jumper pins 25 and 26 on the 40-pin socket, to successfully create a loopback.

Yes I just tried this and it works fine ! This means my board is fine but my PIC is faulty?
 

Possibly.

However another possibility is if the code was recompiled after something was modified. like the configuration register settings. Can you download the original HEX file from the project I uploaded?

Also check the "Configure -> Configuration Settings..." dialog box in MPLAB and ensure the "Configuration Bits set in code" check box is checked, otherwise the settings in the dialog box could possibly override those configuration register settings in the code itself.

BigDog
 
Ok nothings wrong with my board or PIC or the adaptor! The hex file you gave me works ! The configuration bits are set in the code and not via "Configure>> Configuration Settings" Not sure where did I go wrong? How did it stop working randomly?

So basically I spent the whole day today troubleshooting something that works absolutely well!
 

Well at least you've learn some good RS-232 troubleshooting techniques. And another good point, nothing is damaged.

You might want to try creating a new project from scratch for the PIC18F4620 and import the C source file I uploaded.

An exercise I also usually care out when familiarizing myself with the UART of a new chip/platform is to write a software loopback routine which simiply echos back any entered characters to terminal emulation program. Much like the manually shorting of pins 2 and 3 to produce a hardware loopback test.

BigDog
 
Yes thats right, i learnt cool tricks that im sure will be very helpful in future! :)

Thanks for all your help bigdogguru! :) I can now "Mark as Solved" this thread :p

---------- Post added at 16:58 ---------- Previous post was at 16:45 ----------

Ok not quite solved yet :|

I imported the C file, buit the project and programmed the PIC and the SAME ERROR :|

---------- Post added at 17:03 ---------- Previous post was at 16:58 ----------

Maybe I should reinstall MPLAB! It could be corrupt ! What compiler did you use to build it? MPLAB C18 v3.40 is what I used.
 

I imported the C file, buit the project and programmed the PIC and the SAME ERROR :|
Maybe I should reinstall MPLAB! It could be corrupt ! What compiler did you use to build it? MPLAB C18 v3.40 is what I used.

Checking your compiler and IDE versions was my next suggestion.

I currently have installed:

MPLAB v8.70
MPASM v5.41
MPLINK v4.35
C18 v3.35

However, if you currently have installed C18 v3.40, I doubt that is the problem. Maybe it is the process of creating a new project.

What happens if you open the project file of the original project I uploaded? And then try and recompile the project?

BigDog
 

What happens if you open the project file of the original project I uploaded? And then try and recompile the project?

BigDog

Same thing, "Unable to open Com3. Check your port settings". This is after reinstalling MPLAB, and C18 !

---------- Post added at 10:22 ---------- Previous post was at 10:12 ----------

My Pickit3 Setting: Initially I had " Manually select memories and ranges" On and had selected -Program , Configuration, EEPROM and ID. Also Program Memory range was from 0 to ffff. With this the error was : 'Unable to open com3 , please check your port setting"
With just "Program" selected( as shown in the pic below), the above error doesnt come up nor does anything on the hyperterminal !
Whats the correct "memory setting" ?

 

I would recommend selecting "Allow PICKIT 3 to select memories and ranges."

While I do no have a PICKIT, I use a similar setting for most of my programming with the ICD2s and ICD3s.

Manually specifying these parameters can be quite tricky.

BigDog
 

The code just wouldnt work on my board for some unknown reason!
 

Are you sure you have indicated the configuration bits are to be specified in code, not the configuration bits window? Maybe try specifying the configuration bits in the configuration window instead.



Are there any errors or warnings displayed in the build window? Can you post the contents of the Build Window?

The code obviously runs on your board, compiling it on your PC seems to be the issue.

BigDog
 

Here's the pic of the Build Window:


One discrepancy I found between your "confuguration window" and mine is STVREN is set to 01 in yours and 81 in mine. Could the be the culprit- though Im using config in code. Will try setting in the window now...

Thanks

---------- Post added at 12:35 ---------- Previous post was at 12:32 ----------



As i just noticed in the above pic, I do have a warning : Warning [2066] type qualifier mismatch in assignment

This if for the line: putrsUSART(" Hello World! ");

---------- Post added at 13:02 ---------- Previous post was at 12:35 ----------

 
Last edited:

One discrepancy I found between your "confuguration window" and mine is STVREN is set to 01 in yours and 81 in mine. Could the be the culprit- though Im using config in code. Will try setting in the window now...

If the "Configuration Bits set in code" check box is checked, none of the configuration bit settings in the "configuration window" have any effect.

As i just noticed in the above pic, I do have a warning : Warning [2066] type qualifier mismatch in assignment

This if for the line: putrsUSART(" Hello World! ");

Normal. It is an implicit type conversion from "const char *" to "const rom char *", I receive the warning as well.

Do the LEDs light up as expected?

I suspect the oscillator configuration to be the culprit, which should effect the USART but not the LEDs.

BigDog
 

Do the LEDs light up as expected?

I suspect the oscillator configuration to be the culprit, which should effect the USART but not the LEDs.
BigDog

Yes, LEDs light up as expected.
 

Try creating a new project with the following code:

Code:
#include <p18f4620.h>
#include <delays.h>

 
// INTIO67 configures internal oscillator
#pragma config OSC=INTIO67, LVP=OFF, MCLRE=ON , WDT=OFF
 
void setup(void)
{
	/* Clock Setup*/ 
	OSCCON = 0b01110010; //select 8 MHz clock 

	/* Port Set Up*/
	ADCON1 = 0b00001111; //set all pins to digital mode
	TRISD = 0x00;
	TRISA = 0x00;
	TRISB = 0b00000000; 
	TRISC = 0b10000000; // RX is an input, TX is output


	/* Interrupt Setup */
	INTCON = 0x00; /* Clear Registers */
	PIR1 = 0x00;
	PIE1 = 0x00;
	

  // Turn on the 4 LEDs
 // Microchip recommends writing to the PORT Latch rather than the PORT Pins 
	LATBbits.LATB0=1;
	LATBbits.LATB1=1;
	LATBbits.LATB2=1;
	LATBbits.LATB3=1;


	
 
}	
 

void main(void)
{
	setup();
		
	while (1)
	{
	
		Delay10KTCYx(100);

                // Blink the 4 LEDs
               // Microchip recommends writing to the PORT Latch rather than the PORT Pins 
	       LATBbits.LATB0 = ~LATBbits.LATB0;
	       LATBbits.LATB1 = ~LATBbits.LATB1;
	       LATBbits.LATB2 = ~LATBbits.LATB2;
	       LATBbits.LATB3 = ~LATBbits.LATB3;

		
	}
}

See if the LEDs blink repeatedly.

BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top