CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

test program flashing led pic 18f4550 help!!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fletchersk8



Joined: 20 Sep 2011
Posts: 3

View user's profile Send private message Send e-mail

test program flashing led pic 18f4550 help!!!
PostPosted: Tue Sep 20, 2011 6:44 pm     Reply with quote

Hello, this is my first topic, and I'm a newbie when it comes to programming pic 18f4550. My problem is that i started with the most basic program: the flashing led, provided by the pic wizard, but when i run it in my pic it doesn't work. The thing that drove me crazy is when i accidentally touched pin rb7: it started to work!! I reviewed all code and i didn't find any error and i desperately need to see what's going wrong, otherwise i won't be able to develop my senior project, please anyone help me!! this is my source code:
Code:

#include <main.h>
#include <LCD.C>

void main()
{

   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   lcd_init();
   setup_oscillator(OSC_250KHZ|OSC_INTRC|OSC_31250|OSC_PLL_OFF);

    //Example blinking LED program
    while(true){
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);
    }

}

and the main.h code is:
Code:

#include <18F4550.h>
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES PLL1                     //No PLL PreScaler
#FUSES CPUDIV1                  //No System Clock Postscaler
#FUSES INTXT                    //Internal Oscillator, XT used by USB
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(int=250000)
//#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)
#define LED PIN_A1
#define DELAY 1000

I'm using 4.120 version.

Thanks for your help Smile
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 20, 2011 7:43 pm     Reply with quote

Try this simple test program:
http://www.ccsinfo.com/forum/viewtopic.php?t=28833&start=1

And make sure you have a 10K pull-up resistor on the MCLR pin of
the 18F4550.
fletchersk8



Joined: 20 Sep 2011
Posts: 3

View user's profile Send private message Send e-mail

PostPosted: Tue Sep 20, 2011 8:26 pm     Reply with quote

Yes PCM, i already have a 10 k pull-up resistor at MCLR, but i need to run my device at 250 Khz due to an inconsistence between 24lc 256 and usb frequency. This eeprom runs up to 400 Khz. That's why i set the #fuses directives. May it be a bug or something?

The test program doesn´t have the dual oscillator option, so i have to modify it the way i did mine, so i guess: is the oscillator line with a bad configuration?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 20, 2011 8:46 pm     Reply with quote

The i2c bus speed for your eeprom is limited to 400 KHz.

You don't have to run the PIC at that speed. You can run the PIC at
48 MHz and still run the eeprom at 100 KHz or 400 KHz. There is no
requirement to match the PIC speed to the i2c bus speed.
fletchersk8



Joined: 20 Sep 2011
Posts: 3

View user's profile Send private message Send e-mail

PostPosted: Tue Sep 20, 2011 8:55 pm     Reply with quote

PCM programmer wrote:
The i2c bus speed for your eeprom is limited to 400 KHz.

You don't have to run the PIC at that speed. You can run the PIC at
48 MHz and still run the eeprom at 100 KHz or 400 KHz. There is no
requirement to match the PIC speed to the i2c bus speed.


there is a way i can achieve that (example program)?

i was working with a pic 16f887 and when it was running at 4mhz i didn´t get any response from the eeprom. the thing is that: how can i get my eeprom work at the desired frequency with my pic working on a superior frequency? inserting delays in the eeprom routine?

i can post the code if you want to
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 20, 2011 11:44 pm     Reply with quote

Quote:
inserting delays in the eeprom routine?

It's not needed. Don't worry about it. The CCS compiler automatically
adjusts the delays in the #use i2c() library code. You don't have to do it.

Here is a sample program which uses the CCS 25256.c eeprom driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=30346&start=10
Make sure that you have 4.7K pullup resistors on both SDA and SCL.

You can specify other pins than E2 and E0 for sda and scl. Edit the
program so it specifies the PIC pins that your board has connected to
SDA and SCL on the 24LC256.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group