Jump to content

Recommended Posts

Hi,

 

I downloaded the free limitted copy, and I'm using BoostC for this. I've been trying to simply light up an LED on this chip, but I haven't had any luck.

 

I'm not sure what I'm doing wrong. I basically set 4 pins on PORTB high, and the other 4 low, but they're all floating when I power up the PIC. I'm trying to use the internal oscillator, and I thought I set that up correctly....

 

#include <system.h>
#pragma CLOCK_FREQ 4000000 //4MHz
#pragma DATA _CONFIG, _LVP_ON & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _WRT_OFF & _BOR40V
void main()
{
osccon.6 = 1;
osccon.5 = 1;
osccon.4 = 0; 
trisb = 0;
portb = 0x0F;
}

 

Thanks for your help.

Link to post
Share on other sites

I recommend looking at this thread - http://forum.sourceboost.com/index.php?showtopic=2399

The first reply to the thread should give you a good starting point for turning on LEDs (it makes them blink).

Edit: I don't have an 882, but it works in the debugger:

 

#include <system.h>

#pragma CLOCK_FREQ 4000000  // config clock to 4mhz.

// Set configuration fuse.

#pragma DATA _CONFIG, _XT_OSC & _WDT_OFF & _CP_OFF & _PWRTE_OFF

void main()
{
  trisb = 0;		//configure port B pins as output
  while( 1 )	  //endless loop
  {
 portb.0=1;		// set portb pin0 to high.
 portb.1=0;		// set portb pin1 to low.
 delay_ms( 500 );  // pause 0.5 seconds
 portb=0x02;	   // shows hex notation for entering data.
 delay_ms(500);	// you can also write portb=2 in decimal
  }
}

Edited by twomers
Link to post
Share on other sites
Hi,

 

I downloaded the free limitted copy, and I'm using BoostC for this. I've been trying to simply light up an LED on this chip, but I haven't had any luck.

 

I'm not sure what I'm doing wrong. I basically set 4 pins on PORTB high, and the other 4 low, but they're all floating when I power up the PIC. I'm trying to use the internal oscillator, and I thought I set that up correctly....

 

#include <system.h>
#pragma CLOCK_FREQ 4000000 //4MHz
#pragma DATA _CONFIG, _LVP_ON & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _WRT_OFF & _BOR40V
void main()
{
osccon.6 = 1;
osccon.5 = 1;
osccon.4 = 0; 
trisb = 0;
portb = 0x0F;
}

 

Thanks for your help.

 

As a first look at your code I would say that your problem is with the fuse settings.

The PIC16F882 has two config registers so your code should have 2 pragma entries, one for each register.

Eg.

 

#pragma DATA _CONFIG1, _LVP_ON & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT

#pragma DATA _CONFIG2, _WRT_OFF & _BOR40V

 

AlexR

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...