Author Topic: Microchip XC8-Getting started  (Read 5966 times)

0 Members and 2 Guests are viewing this topic.

Offline djsbTopic starter

  • Frequent Contributor
  • **
  • Posts: 912
  • Country: gb
Microchip XC8-Getting started
« on: October 20, 2012, 03:10:17 pm »
I'm trying to light an LED on portb (say B0) of a 16f819 using XC8. I've had a look in the header file to try to find a directive to set bit 0 of port b as an output and then turn it on and then off after a short delay. I usually use CCS C  (which is easy) but would like to use XC8 as well. I had a look at some of the tutorials on Gooligum

http://www.gooligum.com.au/tutorials.html

but they use a different (and simpler) chip. Has anyone used XC8 with any of the mid range devices? If so could you give me a quick example listing I can try and then I can take it from there.
Thanks.

David.

PS Where can I find a list of config bit keyword for this chip that I can use in the #pragma directive to set the config fuses?
There is nothing in the header file.
David
Hertfordshire,UK
University Electronics Technician, London PIC,CCS C,Arduino,Kicad, Altium Designer,LPKF S103,S62 Operator, Electronics instructor. Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. Credited Kicad French to English translator.
 

Offline krish2487

  • Frequent Contributor
  • **
  • Posts: 507
  • Country: dk
Re: Microchip XC8-Getting started
« Reply #1 on: October 20, 2012, 04:23:13 pm »
XC8 is actually repackaged Hitech C compiler with support for PIC18 devices.

pretty much any of the tutorials shown on that wonderful site will workout-of-the-box for XC8

just include the file xc.h in your main.c


As a matter of fact, i have just migrated from hitech to XC8 on linux and it took me less than a couple of hours to familiarize myself with XC8

the manual is a great help.

FWIW

the code for what you intend to do is

Code: [Select]
TRISB=0b00000000;

while(1)
{
PORTB=0b00000001;

__delay_ms(250);

PORTB=0b00000000

__delay_ms(250);
}



Look under the "docs" folder in XC8 installation directory.

there are two html files by name "pic_chipinfo.hml" and "pic18_chipinfo.html"

they contain a list of the devices supported and if you click on a device link, it gives a detailed explanation on how to use the #pragma directive for the config bits.

:-)
If god made us in his image,
and we are this stupid
then....
 

Offline djsbTopic starter

  • Frequent Contributor
  • **
  • Posts: 912
  • Country: gb
Re: Microchip XC8-Getting started
« Reply #2 on: October 20, 2012, 04:53:09 pm »
Thank you.
That's exactly what I needed.

David.
David
Hertfordshire,UK
University Electronics Technician, London PIC,CCS C,Arduino,Kicad, Altium Designer,LPKF S103,S62 Operator, Electronics instructor. Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. Credited Kicad French to English translator.
 

Offline krish2487

  • Frequent Contributor
  • **
  • Posts: 507
  • Country: dk
Re: Microchip XC8-Getting started
« Reply #3 on: October 21, 2012, 05:56:28 am »
You are welcome.
:-)
If god made us in his image,
and we are this stupid
then....
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf