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 CCS Technical Support

Code is working on 16F877 but not work in 18F452
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Onur



Joined: 11 Apr 2004
Posts: 11

View user's profile Send private message

PostPosted: Thu Aug 05, 2004 4:20 pm     Reply with quote

This is code
Code:

#include <18F452.h>

#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=19200, xmit=PIN_E0, rcv=PIN_E1) 

void main()
{
  while(1)
  {
    getc();
    puts("onur");
  }
}


This is list

    CCS PCH C Compiler, Version 3.203, 16465

    Filename: C:\WINDOWS\Desktop\v\ooooo.LST

    ROM used: 220 bytes (1%)
    Largest free fragment is 32548
    RAM used: 6 (0%) at main() level
    7 (0%) worst case
    Stack: 1 locations

    *
    0000: GOTO 00A4
    .................... #include <18F452.h>
    .................... //////// Standard Header file for the PIC18F452 device ////////////////
    .................... #device PIC18F452
    .................... #list
    ....................
    ....................
    .................... #fuses HS,NOWDT,NOPROTECT,NOLVP
    .................... #use delay(clock=20000000)
    .................... #use rs232(baud=19200, xmit=PIN_E0, rcv=PIN_E1)
    001A: MOVLW 08
    001C: MOVWF 00
    001E: BSF F96.1
    0020: BTFSC F84.1
    0022: BRA 0020
    0024: CLRF 06
    0026: BSF 00.7
    0028: BRA 0046
    002A: BCF 00.7
    002C: BRA 0046
    002E: BCF FD8.0
    0030: BTFSC F84.1
    0032: BSF FD8.0
    0034: RRCF 06,F
    0036: BSF 00.6
    0038: BRA 0046
    003A: BCF 00.6
    003C: DECFSZ 00,F
    003E: BRA 002E
    0040: MOVFF 06,01
    0044: BRA 005E
    0046: MOVLW 50
    0048: BTFSC 00.7
    004A: MOVLW 15
    004C: MOVWF 01
    004E: DECFSZ 01,F
    0050: BRA 004E
    0052: NOP
    0054: BTFSC 00.7
    0056: BRA 002A
    0058: BTFSC 00.6
    005A: BRA 003A
    005C: BRA 002E
    005E: GOTO 00BA (RETURN)
    0062: BCF F96.0
    0064: BCF F8D.0
    0066: MOVLW 08
    0068: MOVWF 01
    006A: NOP
    006C: NOP
    006E: NOP
    0070: BSF 01.7
    0072: BRA 0092
    0074: BCF 01.7
    0076: RRCF 07,F
    0078: BTFSC FD8.0
    007A: BSF F8D.0
    007C: BTFSS FD8.0
    007E: BCF F8D.0
    0080: BSF 01.6
    0082: BRA 0092
    0084: BCF 01.6
    0086: DECFSZ 01,F
    0088: BRA 0076
    008A: NOP
    008C: NOP
    008E: NOP
    0090: BSF F8D.0
    0092: MOVLW 50
    0094: MOVWF FE9
    0096: DECFSZ FE9,F
    0098: BRA 0096
    009A: BTFSC 01.7
    009C: BRA 0074
    009E: BTFSC 01.6
    00A0: BRA 0084
    00A2: RETLW 00
    ....................
    .................... void main()
    .................... {
    00A4: CLRF FF8
    00A6: BCF FD0.7
    00A8: CLRF FEA
    00AA: CLRF FE9
    00AC: BSF FC1.0
    00AE: BSF FC1.1
    00B0: BSF FC1.2
    00B2: BCF FC1.3
    00B4: BCF F96.0
    00B6: BSF F8D.0
    .................... while(1)
    .................... {
    .................... getc();
    00B8: BRA 001A
    .................... puts("onur");
    00BA: CLRF 06
    00BC: MOVF 06,W
    00BE: RCALL 0004
    00C0: IORLW 00
    00C2: BZ 00CC
    00C4: INCF 06,F
    00C6: MOVWF 07
    00C8: RCALL 0062
    00CA: BRA 00BC
    00CC: MOVLW 0D
    00CE: MOVWF 07
    00D0: RCALL 0062
    00D2: MOVLW 0A
    00D4: MOVWF 07
    00D6: RCALL 0062
    .................... }
    00D8: BRA 00B8
    .................... }
    ....................
    00DA: SLEEP

    Configuration Fuses:
    Word 1: 2200 HS NOOSCSEN
    Word 2: 0E0F BROWNOUT WDT128 NOWDT BORV20 NOPUT
    Word 3: 0100 CCP2C1
    Word 4: 0081 STVREN NODEBUG NOLVP
    Word 5: C00F NOPROTECT NOCPD NOCPB
    Word 6: E00F NOWRT NOWRTD NOWRTB NOWRTC
    Word 7: 400F NOEBTR NOEBTRB


Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Thu Aug 05, 2004 7:04 pm     Reply with quote

The source code compiles exactly as mine and works perfectly. Now I did test it at 10MHz because I didn't have a 20Mhz crystal at home. I think either your circuit it bad or your chip. Describe you circuit to us.
Onurr
Guest







PostPosted: Fri Aug 06, 2004 4:39 am     Reply with quote

My circuit board is works fine. If I use 16f877 works fine...
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Fri Aug 06, 2004 4:46 am     Reply with quote

The code works just fine on my circuit board and 18f452. Must be your chip or the circuit. For all I know, you circuit is crap and the 16F877 just barely works where there is a slight electrical difference in the 18F452 that is causing it not to work. If you want help, then you should answer the questions. If you don't, keep using the 16F877.
Guest








PostPosted: Fri Aug 06, 2004 9:07 am     Reply with quote

ok I will make other demo board. I and I will change my 18F452.
Thank you...
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Aug 07, 2004 7:18 am     Reply with quote

Onur,

Mark didn't say you have to create a new demo board, he just asked you to describe the hardware you are using because this is the most likely reason left for failure. I asked you too for a description of your RS-232 interface and you never answered to that either.

You can create a new demo board, but without design changes it is very likely to fail again. What do you have against describing your schematics? Afraid of us copying your design? We have already seen so many RS-232 designs in this forum that I don't think you can come up with something completely new.

It's even possible that the problem is not in your design after all, reading this forum you can find many other causes for RS232 to fail. Although without checking your hardware it would be a waste of time to go into that deeper now.
Guest








PostPosted: Mon Aug 23, 2004 9:15 pm     Reply with quote

ckielstra

I'm sorry fistly I cant understand your questions. You are wrong thing about me. I want to learn something about pic.

I'm using simple rs232 interface. max232 and 4 cap. (10 uF)
and I connected to pic and com port. that is all

when I use this demo board 877 works but 452 cant work.

I'm saying not rs232 I'm talking about many program.
I tryed lots of program about 18f852 but lots of time program cant work. but sometime code work but some time cant work. I said myself maybe osilator must be change. then I used 4 mhz osi and code sometime works. If used 10 mhz osi some time works some times dont work..

and 10mhz osi and pllx4 newer worked.

If you want to know more things please ask me......
Ttelmah
Guest







PostPosted: Tue Aug 24, 2004 3:05 am     Reply with quote

Anonymous wrote:
ckielstra

I'm sorry fistly I cant understand your questions. You are wrong thing about me. I want to learn something about pic.

I'm using simple rs232 interface. max232 and 4 cap. (10 uF)
and I connected to pic and com port. that is all

when I use this demo board 877 works but 452 cant work.

I'm saying not rs232 I'm talking about many program.
I tryed lots of program about 18f852 but lots of time program cant work. but sometime code work but some time cant work. I said myself maybe osilator must be change. then I used 4 mhz osi and code sometime works. If used 10 mhz osi some time works some times dont work..

and 10mhz osi and pllx4 newer worked.

If you want to know more things please ask me......

Immediate suspicion is the crystal.
The oscillator circuit on the 18F chips, has higher gain that that on the 16F chips. The PLL will not work properly (will run off frequency), if even slightly overdriven. Hence it may be necessary to add a series resistor between the crystal, and the clock input pin (typically about 50ohms). The latter revisions of the chips are better in this regard, and normally the plain oscillator (without the PLL), is not so badly affected. I suspect you have a particularly high gain crystam, and it is perhaps locking onto a higher overtone. The code then won't work, since the UART timings will be completely wrong. Presumably you have the right loading capacitors on the crystal?.

Best Wishes
Onurr
Guest







PostPosted: Tue Aug 24, 2004 2:56 pm     Reply with quote

I used 22pf Condancator for 10 mhz osilator.

where can I find pll osilator? I dont know what is look like
where can I find schemtic about pll oscilator.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Aug 25, 2004 3:18 am     Reply with quote

Onur,

Thanks for describing your RS232 circuit. In this forum many different rs-232 circuits have been described and many things can go wrong here. Your setup is very standard and it isn't likely this is causing your problems.

This is the first time you mention other programs to fail, this changes the whole perspective and we will have to look for the error to be in another circuit than the RS232. Like Ttelmah said, the oscillator is the most likely cause of your problems.

2 x 22pf capacitors for a 10MHz crystal seem ok to me.

Quote:
where can I find pll osilator? I dont know what is look like
The PLL oscillator is in the PIC. You yourself mentioned using it by selecting the pll4x option.

Have you tried adding a series resitors as Ttelmah suggested?

Another difference between PIC16 and PIC18 is that the PIC18 requires a parallel cut crystal, series cut crystals are not allowed as this may give an unspecified frequency.

If you want to make sure the oscillator is the problem you could write a small test program that toggles an output every 10 seconds. Use a voltmeter or LED to check the frequency of this output changing, if this is not every 10 seconds you know for sure it is the oscillator.
onurr
Guest







PostPosted: Wed Aug 25, 2004 4:00 pm     Reply with quote

Quote:
Have you tried adding a series resitors

I must add 2 resistor or 1 resistor ?
osc1 pin or osc 2 pin?

Quote:
Another difference between PIC16 and PIC18 is that the PIC18 requires a parallel cut crystal, series cut crystals are not allowed as this may give an unspecified frequency.



when I buy crystal I must be say parallel cut crystal
or those are same crystal


Quote:
If you want to make sure the oscillator is the problem you could write a small test program that toggles an output every 10 seconds. Use a voltmeter or LED to check the frequency of this output changing, if this is not every 10 seconds you know for sure it is the oscillator.


yes I tested this:) this is changing maybe 10sec some time maybe 13 sec[/quote]
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 26, 2004 2:27 am     Reply with quote

I'm not an crystal expert, but looking at the PIC18 datasheets and searching the web I found the answers to all your questions. Maybe you could try and do the same?
Quote:
I must add 2 resistor or 1 resistor ?
osc1 pin or osc 2 pin?
It depends on the type of crystal you are using whether you need a resistor or not. Can you get more information from your supplier? Most crystals are AT-cut or AT-strip cut. For the AT-cut you don't need the resistor, for the AT-strip cut it may be required.
See PIC18F252 datasheet Figure 2-1: 1 resistor on osc2 pin. No value for the resistor is specified but something like 330 ohm should do it.

Quote:
when I buy crystal I must be say parallel cut crystal
or those are same crystal
You must specify series or parallel resonance when you buy the crystal. Both the same physical crystal, but they are specified for different frequencies. Using a series crystal in a parallel circuit (like the PIC uses) will result in a unspecified frequency and might even be out of manufacturer's specification. See this article for more information.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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