Device configuration

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Re: Device configuration

Postby user2009 » Mon Jul 21, 2014 3:01 pm

Without reading that configuration, your defines are wrong.
Code: Select all
#define _XTAL_FREQ = 20000000;

should probably be
Code: Select all
#define _XTAL_FREQ  20000000UL

I dont know what the intention of the other define, will it even compile?
user2009
 
Posts: 13
Joined: Tue Jul 01, 2014 11:48 am
PIC experience: Professional 2-5 years with MCHP products

Re: Device configuration

Postby Dimebag » Mon Jul 21, 2014 3:05 pm

I am lost again if its just a warning or, in fact I have a problem. (BlinkLED.c:4: warning: (111) redefining preprocessor macro "__delay_ms")
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Mon Jul 21, 2014 3:09 pm

Thank you, user2009
May I ask why #define _XTAL_FREQ 20000000UL?
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby user2009 » Mon Jul 21, 2014 3:12 pm

__delay_ms() is part of the library, you just need to include xc.h to use it. You redefine that function/macro by doing this
Code: Select all
define _delay_ms();

(you dont want to do that)

Edit: A macro is just text replacement.
Code: Select all
#define SOMETHING = 20;
unsigned char test = SOMETHING;

will be expanded to
Code: Select all
unsigned char test = = 20;;

You can see whats wrong with it that way.

As the others mentioned thats really basic stuff, get a tutorial/book and follow it.
Last edited by user2009 on Mon Jul 21, 2014 3:23 pm, edited 1 time in total.
user2009
 
Posts: 13
Joined: Tue Jul 01, 2014 11:48 am
PIC experience: Professional 2-5 years with MCHP products

Re: Device configuration

Postby Dimebag » Mon Jul 21, 2014 3:20 pm

#define delay_ms(); Complied. Why?
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Mon Jul 21, 2014 3:43 pm

__delay_ms() is part of the library, you just need to include xc.h to use it.
if you read the posting I already included xc.h
As the others mentioned thats really basic stuff, get a tutorial/book and follow it.
Last edited by Dimebag on Mon Jul 21, 2014 3:47 pm, edited 1 time in total.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Mon Jul 21, 2014 3:46 pm

If you know of any useful tutorials and books I should be reading, please let me know.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Mon Jul 21, 2014 3:57 pm

user2009, I just read all 6 posts you have done here. Help someone else. Thank you for your assistance.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Mon Jul 21, 2014 9:23 pm

user2009 wrote:Without reading that configuration, your defines are wrong.
Code: Select all
#define _XTAL_FREQ = 20000000;

should probably be
Code: Select all
#define _XTAL_FREQ  20000000UL

There is nothing wrong with the original version.
It is used as part of a calculation inside another compiler defined macro.

I dont know what the intention of the other define, will it even compile?

I think it was an attempt to stop MPLABX putting a red squiggle under _delay_ms() when it is invoked. Yes, the define should NOT be there.
That is a bug in the MPLABX editor, it compiles just fine,
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby user2009 » Tue Jul 22, 2014 6:35 am

You need to obtain some general basic knowledge of C language.
user2009
 
Posts: 13
Joined: Tue Jul 01, 2014 11:48 am
PIC experience: Professional 2-5 years with MCHP products

PreviousNext

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 34 guests