Device configuration

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

Re: Device configuration

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

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.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Mon Jul 21, 2014 12:36 pm

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?
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Mon Jul 21, 2014 12:46 pm

Which precise compiler are you talking about now?
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 Dimebag » Mon Jul 21, 2014 12:52 pm

mplabx xc
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Mon Jul 21, 2014 1:03 pm

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() ?
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 Dimebag » Mon Jul 21, 2014 1:09 pm

I am looking for it Rick.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Mon Jul 21, 2014 1:15 pm

  • 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.
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 Dimebag » Mon Jul 21, 2014 1:48 pm

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.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Mon Jul 21, 2014 1:57 pm

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".
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 Dimebag » Mon Jul 21, 2014 2:41 pm

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.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

PreviousNext

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 8 guests

cron