Page 5 of 12
Re: Device configuration
Posted:
Mon Jul 21, 2014 12:09 pm
by Dimebag
I understand that you guys are helping me a lot. I am not trying be un-cooperative I am just busy trying to do research on the things that have already been explained to me. The code I have been working on is to show that I am listening to you and trying to learn better programming skills. I know it sounded like I wasn't listening to Ric, I was trying to do research on the Generated Assembly Code which I found difficult to find explanations of it. I also looked at the delays.h and now doing some research on it as well to find out what the complier does with delays.h.
Re: Device configuration
Posted:
Mon Jul 21, 2014 12:36 pm
by Dimebag
I am trying to understand the delays.h
- Code: Select all
/* Delay of exactly 1 Tcy */
#define Delay1TCY() _delay(1)
/* Delay of exactly 10 Tcy */
#define Delay10TCY() _delay(10)
/*Delay1TCYx */
void Delay1TCYx(unsigned char);
Why has Delay?TCY(), have "_delay(1), _delay(10)" where as Delay1TCYx(unsigned char) are made this way?
Re: Device configuration
Posted:
Mon Jul 21, 2014 12:46 pm
by ric
Which precise compiler are you talking about now?
Re: Device configuration
Posted:
Mon Jul 21, 2014 12:52 pm
by Dimebag
mplabx xc
Re: Device configuration
Posted:
Mon Jul 21, 2014 1:03 pm
by ric
Ahh, you are playing around with the delays.h in the "plib" folder.
Why bother? Is there some reason you can't use __delay_ms() ?
Re: Device configuration
Posted:
Mon Jul 21, 2014 1:09 pm
by Dimebag
I am looking for it Rick.
Re: Device configuration
Posted:
Mon Jul 21, 2014 1:15 pm
by ric
- Open the XC8 user manual.
- Press Control and F to activate find.
- search for "__delay_ms"
This is exactly what I asked you to do last night.
Re: Device configuration
Posted:
Mon Jul 21, 2014 1:48 pm
by Dimebag
Thanks Ric,
__delay_ms() is a macro? So I need to indicate the _XTAL_FREQ = XXX as well. XC8 user manual (page 330) I am still trying to get my head around C. Please give me a couple of days to read the manual over some more.
Re: Device configuration
Posted:
Mon Jul 21, 2014 1:57 pm
by ric
It doesn't really matter what it is.
Just use it as they describe, and define your _XTAL_FREQ correctly, and it will "just work".
Re: Device configuration
Posted:
Mon Jul 21, 2014 2:41 pm
by Dimebag
I think this is correct.
- Code: Select all
#include <xc.h>
#define _delay_ms();
#define _XTAL_FREQ = 20000000;
//Configurations and Fuses
#pragma config OSC = HS, OSCS = OFF,PWRT = ON,BOR = OFF
#pragma config BORV = 45,WDT = OFF,WDTPS = 1,CCP2MUX = OFF
#pragma config STVR = OFF,LVP = OFF,DEBUG = OFF
#pragma config CP0 = OFF,CP1 = OFF,CP2 = OFF,CP3 = OFF,CPB = OFF,CPD = OFF
#pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF,WRT3 = OFF,WRTB = OFF,WRTC = OFF,WRTD = OFF
#pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF,EBTR3 = OFF,EBTRB = OFF
Should mean that OSC is running at 20 Hz, allowing __delay_ms() to be available to use as delay timing.