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

Need Help on 18F1320

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



Joined: 20 Jul 2004
Posts: 3

View user's profile Send private message MSN Messenger ICQ Number

Need Help on 18F1320
PostPosted: Tue Jul 20, 2004 9:12 am     Reply with quote

Hello, I'm newbeez with 18F1320 and do not succed to make work this one Sad

I think my problem is to configure fuses.


I did a a program to send "123456" through the RS232.
It did it when I put on power but some time it did it again Rolling Eyes


Do anybody could help me please ?
Do you have an exemple of project to give ?


Djipe.
Guest








PostPosted: Tue Jul 20, 2004 6:07 pm     Reply with quote

Can u elaborate your problem... it seems you don't experience problem as stated in your post...
djipe



Joined: 20 Jul 2004
Posts: 3

View user's profile Send private message MSN Messenger ICQ Number

PostPosted: Wed Jul 21, 2004 3:11 am     Reply with quote

My problem is, I don't know how to configure fuses with CCS when create a wisard project.

So, I try to configure it but all my program reset alone Confused


I think, the best will be any body whose work with 18F1320 give me an exemple of program configured for this pic.
With this one, I can analyse fuses and use it for future.
ttelmah
Guest







Re: Need Help on 18F1320
PostPosted: Wed Jul 21, 2004 3:57 am     Reply with quote

djipe wrote:
Hello, I'm newbeez with 18F1320 and do not succed to make work this one Sad

I think my problem is to configure fuses.


I did a a program to send "123456" through the RS232.
It did it when I put on power but some time it did it again Rolling Eyes


Do anybody could help me please ?
Do you have an exemple of project to give ?


Djipe.

I'm afraid you are going to have to do some work yourself.
Read the chips data sheet. This gives the fuses. Then you need to work out which ones _you_ want set for your project (this changes with the hardware you are using, so there is no 'generic' answer, except when people are working with known hardware combinations, like some of the 'prototyping' boards). Then the 'symbolic' names are listed in the header file for the chip. If you cannot work out how these relate to the real fuses, post back, and somebody can then help.
The most likely reason for a 'repeated' printout, is that the hardware watchdog is enabled, and the code is running 'off the end', or sitting in an infinite loop. The watchdog, then triggers, restarting the processor. This is disabled with the 'NOWDT' fuse setting.
So a bit of code like:
main() {
printf("test\n");
delay_ms(5);
}

With the watchdog timer enabled, will actually print:

test
test
test

etc., as the code runs off the end of the main loop, hits the hidden 'sleep' instruction that CCS place there, goes to sleep, and then the watchdog triggers.

Best Wishes
Guest








Re: Need Help on 18F1320
PostPosted: Wed Jul 21, 2004 11:49 am     Reply with quote

ttelmah wrote:
I'm afraid you are going to have to do some work yourself.
Read the chips data sheet. This gives the fuses.


I did it many time but .... Crying or Very sad


I do not success to use it.
I begin to borred. May be thi PIC will have to learn to fly.


I've implemented a voltage regulator, setup my capacitor the nearest of the PIC VDD.
I did this modification, because I've seen that when I shut down power, the pic look's working correctly Shocked


And now, with this modification, the result is worst Sad


For two weeks, I've been trying and trying .... and still not have any result...

If any body has work in the past with the 18F1320, Please, could you send me your Fuses to do button-LED and a PRINTF.
Thanks
chingB



Joined: 29 Dec 2003
Posts: 81

View user's profile Send private message

PostPosted: Wed Jul 21, 2004 6:20 pm     Reply with quote

Try this code below:

Code:


#include <18F1320.h>             // MCU specific library
#device *=16
#fuses HS,NOLVP,NOWDT,NOPROTECT,MCLR
#use delay (clock=20000000)       // 20MHz clock

#define LED    PIN_A2

void led_func()
{
      output_high(LED);
      delay_ms(1000);
      output_low(LED);
      delay_ms(1000);
}

main()
{
   delay_ms(2000);
   setup_adc_ports(NO_ANALOGS);

   while(TRUE)
   {
      led_func();
   }
}




The code below uses the internal 8MHz oscillator

Code:


#include <18F1320.h>             // MCU specific library
#device *=16
#fuses INTRC_IO,NOLVP,NOWDT,NOPROTECT,MCLR
#use delay (clock=8000000)       // 8MHz clock

#byte OSCCON = 0xFD3
#byte SPBRGH = 0xFB0
#byte SPBRG  = 0xFAF
#byte TXREG  = 0xFAD
#byte RCSTA  = 0xFAB
#byte RCREG  = 0xFAE

#bit  BRG16  = 0xFAA.3
#bit  BRGH   = 0xFAC.2
#bit  SYNC   = 0xFAC.4
#bit  SPEN   = 0xFAB.7
#bit  TX9    = 0xFAC.6
#bit  TXEN   = 0xFAC.5
#bit  TXIF   = 0xF9E.4
#bit  TXIE   = 0xF9D.4

#bit  RX9    = 0xFAB.6
#bit  CREN   = 0xFAB.4
#bit  RCIF   = 0xF9E.5
#bit  FERR   = 0xFAB.2
#bit  OERR   = 0xFAB.1

#define LED    PIN_A2

char rcvChar = 0;
char txvChar = 0;

#int_rda
void rda_isr()
{
   rcvChar = RCREG;
   if (OERR){
      CREN = 0;
      #asm nop #endasm
      CREN = 1;
   }

}

void led_func()
{
      output_high(LED);
      delay_ms(1000);
      output_low(LED);
      delay_ms(1000);
}


main()
{
   delay_ms(2000);
   setup_oscillator(OSC_8MHZ|OSC_INTRC);
   setup_adc_ports(NO_ANALOGS);

   SPBRGH = 0;
   SPBRG = 16;
   BRG16 = 1;
   BRGH = 1;
   SYNC = 0;
   SPEN = 1;
   TX9 = 0;
   TXEN = 1;
   TXIF = 0;

   RX9 = 0;
   CREN = 1;
   RCIF = 0;

   enable_interrupts(int_rda);
   //enable_interrupts(int_tbe);
   enable_interrupts(global);

   while(TRUE)
   {
      led_func();
      TXREG = 'A';
      TXREG = ' ';
      TXREG = rcvChar;
   }
}



I hope this helps.... I agree with ttelmah that you need to read the data sheets ---> u get a lot of information there!!! one thing try search this forum coz there are a lot of sample snippet that uses PIC18F1320... razz:
djipe



Joined: 20 Jul 2004
Posts: 3

View user's profile Send private message MSN Messenger ICQ Number

PostPosted: Thu Jul 22, 2004 1:15 pm     Reply with quote

chingB wrote:
I hope this helps.... I agree with ttelmah that you need to read the data sheets ---> u get a lot of information there!!! one thing try search this forum coz there are a lot of sample snippet that uses PIC18F1320... razz:


Thank you for your code, it's very interesting.

In my schematic I've found a big big big mistake Rolling Eyes
I use a christal and I set up my capacitors to the +5V Embarassed
It's the reason why I had so much reset

Now, I now I'll never do it again Wink


One more time, thank you.

Djipe.
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