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.
Heya
The code FINALLY works! =D After struggling for more than a month, IT FINALLY WORKS ! Ive never been so happy in my life :p

I'm glad to hear it.

I pulled out Jumper J20 and J21 and the code works ! ( the first time code worked with the 2 jumpers on though) I now have J20-J23 out !

Jumper J20-J23? What development board are you using? I was under the impression you were using a PICDEM 2 Plus, obviously I was in error.

Were J20-J23 jumpers controlling the line access to the MAX232?

BigDog
 

I am using PICDEM2 Plus.

From the board manual : J20-J23 is for PIC MCU to I2C bus

---------- Post added at 11:36 ---------- Previous post was at 11:30 ----------

How do you enter a new line?

putrsUSART("/n/r") doesn't seem to work.
 

I am using PICDEM2 Plus.

From the board manual : J20-J23 is for PIC MCU to I2C bus

You must be using a different revision of the PICDEM2 PLUS board, my board only has jumpers: J6, J7 and J9 - Circa 2006

How do you enter a new line?

putrsUSART("/n/r") doesn't seem to work.

Use backward slashes, not forward slashes.

Try:

Code:
putrsUSART("\n\r");

BigDog
 
Oh yes the backward slashes works! :)

My board assembly suggests its "R6", meaning revision 6 maybe?
 

Interesting.

Both my boards have "30 REV 6" on the back upper left corner and "PICDEM™ 2 PLUS DEMO BOARD ©2006" on the front below the LCD.

BigDog
 

I have "1-R6" on the back & "02-01630-1 DEMO BOARD c 2010" below LCD
 

J20 and J21 are TXD and RXD respectively!

Also J19 and J18 are Tx and Rx for RS232!

Why are there 2 jumpers for Tx and Rx?? One needs to be in place at a time?
 

Why are there 2 jumpers for Tx and Rx?? One needs to be in place at a time?

Good Question. Convenience? It does seem to be redundant.

Have you successfully driven the LCD yet?

The previous version of the PICDEM 2 PLUS board used an LCD which did not seem to be completely compatible with the Hitachi HD44780.

Specifically the busy flag appeared be implemented incorrectly, which required the use of delays rather than monitoring the busy flag before issue the next command.

BigDog
 

Yes the LCD works allright so far!

Previous versions used Port A for RS, RW and E and Port D for data lines. In the new version, all the lines are controlled via Port D.
 

Did you use the busy flag in your LCD routines or just a delay before issuing the next command?

I curious as to whether the changed the LCD.

BigDog
 

I used a function which is called to wait until the LCD has finished working and is available for further writing. This was provided by microchip !

Code:
void WaitLCD(void)
{
  	UINT8_T Status;                 		// Local buffer for LCD status
	UINT16_T TimeOut_Counter = 0;

  	LCD_RS = CLEAR;                 		// Let the LCD know it's getting a command
  	LCD_RW = READ;                  		// Specify a read command
  do
  {
    Status = ReadByte();            		// Get LCD state
	if (TimeOut_Counter == TimeOut_Max)		// WaitLCD Timeout Error
	{
		do{	LATBbits.LATB3 = LATBbits.LATB2 = LATBbits.LATB1 = ENABLE;	}while(1);				
	}			
	TimeOut_Counter++;	
  } while (Status & 0x80);          // If bit 7 high => LCD busy
  	LCD_RW = WRITE;                 // LCD is now in read mode (MCU in write mode)
	ClrWdt();						// Precautionary Clear of Watch DOG Timer
	TimeOut_Counter = 0;
}
 

They must have changed the LCD, the following code checks the busy flag (bit 7) of the LCD. The LCDs on several previous versions of Microchip development boards did not properly support this HD44780 compatible feature.

That's Good News.


Code:
void WaitLCD(void)
{
  	UINT8_T Status;                 		// Local buffer for LCD status
	UINT16_T TimeOut_Counter = 0;

  	LCD_RS = CLEAR;                 		// Let the LCD know it's getting a command
  	LCD_RW = READ;                  		// Specify a read command
  do
  {
    Status = ReadByte();            		// Get LCD state
	if (TimeOut_Counter == TimeOut_Max)		// WaitLCD Timeout Error
	{
		do{	LATBbits.LATB3 = LATBbits.LATB2 = LATBbits.LATB1 = ENABLE;	}while(1);				
	}			
	TimeOut_Counter++;	
  } [COLOR="#FF0000"]while (Status & 0x80);          // If bit 7 high => LCD busy[/COLOR]
  	LCD_RW = WRITE;                 // LCD is now in read mode (MCU in write mode)
	ClrWdt();						// Precautionary Clear of Watch DOG Timer
	TimeOut_Counter = 0;
}

BigDog

---------- Post added at 04:55 ---------- Previous post was at 04:48 ----------

What is the next step with your project?

Do you need any other assistance?

BigDog
 

The next part of the project involves measuring frequency of an inductive loop! Currently reading up on timers0 and timer 1 !

Im damn sure I will get lost and will pop here for assistance!
 

What will be the required measurable frequency range of the system?
BigDog

Not sure yet as the loop is not ready yet ! I am guessing it would be around 10kHz or something similar!
 

Hi

I have timer 1 which counts the rising edge of the input signal on RC1. Here is the part of code which I believe isn't working as required! The output on my LCD and Hyperterminal is : åRçÏÙ [without or without anything on RC1]

Code:
	freq = ReadTimer1(); // get frequency reading from timer1 counter mode
	ultoa(freq,str,10);
	
	LCDGoto(0,0);
	LCDWriteStr("Counter:");
	LCDWriteStr(str);

	
	
	putrsUSART(str);
	putrsUSART("\n\r");


---------- Post added at 15:09 ---------- Previous post was at 15:08 ----------

"str' is initialised as char str[10]
 

"str' is initialised as char str[10]

At first glance, Reference: Microchip C18 Library User's Manual, Section: Data Conversion Functions, ultoa() function

ultoa

Function: Convert an unsigned long integer to a string.
Include: stdlib.h
Prototype: char * ultoa( unsigned long value, char * string);






Arguments: value
An unsigned long integer to be converted.
string
Pointer to ASCII string that will hold the result.
Remarks: This function converts the unsigned long integer in the argument value
to a ASCII string representation. string must be long enough to hold the ASCII representation,
including a trailing null character.
This function is an MPLAB C18 extension to the ANSI required
libraries.
Return Value: Pointer to the result string.
File Name: ultoa.asm

A 32-bit unsigned long datatype can require 10 characters for representation in a string, plus a trailing null character. Try redefining string buffer as str[11].

I'll review your code for any other possible issues.

BigDog

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

Can you post your entire code listing? It would make it much easier to troubleshoot the issue.

Also what version of the C18 compiler are you using?

BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top