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

PIC16F873 and RDA

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



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PIC16F873 and RDA
PostPosted: Sat Sep 11, 2004 10:06 am     Reply with quote

Hi all:

this simple program doesn't works � any idea ?

Regards;
Joan

#include <16F873.h>
#use delay(clock=10000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)

char i;

#int_rda
void serial_isr()
{
i = getc ();
putc ('*');

}


main()
{
delay_ms (250); // Start-up Delay

enable_interrupts(INT_RDA); // Enable RS-232 Interrupt
enable_interrupts(GLOBAL); // Enable Gobal Interrupts

while(1)
{

}
}
_________________
I Came. I Saw. I Won.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 11, 2004 11:52 am     Reply with quote

It should work.

I assume you're sending characters to the PIC by typing
them in from your PC keyboard, with Hyperterminal or
a similar program.

How are you connecting the PIC to a serial port on your PC ?

Are you using a MAX232-type RS232 level converter chip ?


Also, I would add the ERRORS parameter to the end of your #use
rs232 statement, like this:
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
Joan



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Sat Sep 11, 2004 12:53 pm     Reply with quote

Hi all:

yes I'm uing a Serial PC Port with a RS232 to TTL converter that is working correctly ( because if I connect toghether TTL-RX and TTL-TX and send chars form PC I receive them again ). So the problem is on the program.

If I put these lines on main it sends "*" every time it receive a char from port.

while(1)
{
i = getc ();
putc ('*');
}

Regards;

Joan
_________________
I Came. I Saw. I Won.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 11, 2004 2:45 pm     Reply with quote

Please post your version of the PCM compiler.

I'll install that version and compile your program,
and I'll look at the ASM code to see if there is a problem.
I'll do it later in the day.
Joan



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Sat Sep 11, 2004 3:41 pm     Reply with quote

Hi:

CCS version I used was 3.187. I checked all connections and seems OK, also I tryed with a new PIC16F873, but same results.

Best Regards;

Joan
_________________
I Came. I Saw. I Won.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 12, 2004 1:26 pm     Reply with quote

I installed PCM vs. 3.187, compiled your program, and programmed it
into a 16F877 (I don't have a 16F873). It worked.

But there could still be a problem, because the two chips have different
resources and the compiler generates different code for each chip.

Can you compile the program that you posted above, and send the
.LST file to me in a PM. (Or post it here if you want).

I want to see if your .LST file matches what I get.
Joan



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Mon Sep 13, 2004 12:22 pm     Reply with quote

Hi, here it is the output file for the program I posted :
Regads;
Joan
-----------------------------------------------------------------------------------

CCS PCM C Compiler, Version 3.187, 16465

Filename: C:\Archivos de programa\PICC\Examples\16F873\RDA.LST

ROM used: 111 (3%)
Largest free fragment is 2048
RAM used: 15 (8%) at main() level
16 (8%) worst case
Stack: 2 worst case (1 in main + 1 for interrupts)

*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 058
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 26
0008: MOVF 7F,W
0009: MOVWF 25
000A: MOVF 0A,W
000B: MOVWF 2D
000C: CLRF 0A
000D: SWAPF 25,F
000E: MOVF 04,W
000F: MOVWF 27
0010: MOVF 20,W
0011: MOVWF 28
0012: MOVF 21,W
0013: MOVWF 29
0014: MOVF 22,W
0015: MOVWF 2A
0016: MOVF 23,W
0017: MOVWF 2B
0018: MOVF 24,W
0019: MOVWF 2C
001A: BCF 03.7
001B: BCF 03.5
001C: MOVLW 8C
001D: MOVWF 04
001E: BTFSS 00.5
001F: GOTO 022
0020: BTFSC 0C.5
0021: GOTO 035
0022: MOVF 27,W
0023: MOVWF 04
0024: MOVF 28,W
0025: MOVWF 20
0026: MOVF 29,W
0027: MOVWF 21
0028: MOVF 2A,W
0029: MOVWF 22
002A: MOVF 2B,W
002B: MOVWF 23
002C: MOVF 2C,W
002D: MOVWF 24
002E: MOVF 2D,W
002F: MOVWF 0A
0030: SWAPF 26,W
0031: MOVWF 03
0032: SWAPF 7F,F
0033: SWAPF 7F,W
0034: RETFIE
0035: BCF 0A.3
0036: GOTO 037
.................... #include <16F873.h>
.................... //////// Standard Header file for the PIC16F873 device ////////////////
.................... #device PIC16F873
.................... #list
....................
.................... #use delay(clock=10000000)
*
0042: MOVLW 2F
0043: MOVWF 04
0044: MOVF 00,W
0045: BTFSC 03.2
0046: GOTO 056
0047: MOVLW 03
0048: MOVWF 21
0049: CLRF 20
004A: DECFSZ 20,F
004B: GOTO 04A
004C: DECFSZ 21,F
004D: GOTO 049
004E: MOVLW 3C
004F: MOVWF 20
0050: DECFSZ 20,F
0051: GOTO 050
0052: NOP
0053: NOP
0054: DECFSZ 00,F
0055: GOTO 047
0056: BCF 0A.3
0057: GOTO 068 (RETURN)
.................... #fuses HS,NOWDT,NOPROTECT,NOLVP
.................... #use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)
....................
.................... char i;
....................
.................... #int_rda
.................... void serial_isr()
.................... {
.................... i = getc ();
*
0037: BTFSS 0C.5
0038: GOTO 037
0039: MOVF 1A,W
003A: MOVWF 2E
.................... putc ('*');
003B: MOVLW 2A
003C: BTFSS 0C.4
003D: GOTO 03C
003E: MOVWF 19
.................... }
....................
....................
003F: BCF 0C.5
0040: BCF 0A.3
0041: GOTO 022
.................... main()
.................... {
*
0058: CLRF 04
0059: MOVLW 1F
005A: ANDWF 03,F
005B: MOVLW 06
005C: BSF 03.5
005D: MOVWF 1F
005E: MOVLW 40
005F: MOVWF 19
0060: MOVLW 26
0061: MOVWF 18
0062: MOVLW 90
0063: BCF 03.5
0064: MOVWF 18
.................... delay_ms (250); // Start-up Delay
0065: MOVLW FA
0066: MOVWF 2F
0067: GOTO 042
....................
.................... enable_interrupts(INT_RDA); // Enable RS-232 Interrupt
0068: BSF 03.5
0069: BSF 0C.5
.................... enable_interrupts(GLOBAL); // Enable Gobal Interrupts
006A: MOVLW C0
006B: BCF 03.5
006C: IORWF 0B,F
....................
.................... while(1)
.................... {
....................
.................... }
006D: GOTO 06D
.................... }
....................
006E: SLEEP

Configuration Fuses:
Word 1: 3F7A HS NOWDT NOPUT NOPROTECT BROWNOUT NOLVP NOCPD NOWRT NODEBUG
-----------------------------------------------------------------------------------
_________________
I Came. I Saw. I Won.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 13, 2004 12:31 pm     Reply with quote

It's identical to my .LST file. I'll have to look at the problem
further, later in the day.
Kieran



Joined: 28 Nov 2003
Posts: 39
Location: Essex UK

View user's profile Send private message

PostPosted: Mon Sep 13, 2004 1:13 pm     Reply with quote

Sounds like hardware to me, you could be receiving rubbish, look at the Rx pin with a scope while you hold down the PC U key (55 Hex) and you should see the start bit and the following data bits.

I always set the data direction for all the ports.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 13, 2004 6:12 pm     Reply with quote

I looked at the code and I don't really see anything wrong.
The fact that I can take the HEX file for the 16F873, and run
it OK on my 16F877 board is important. The 16F877 has
more RAM and ROM than the F873, but I looked at the F873
code, and it's only using RAM locations that are truly available
to the F873.

So, based on the information that I've been given, I don't have
a solution.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

Works on the F876
PostPosted: Mon Sep 13, 2004 6:22 pm     Reply with quote

I tested it on the F876 and it works fine here too... Sure looks like a HW problem of some sort, strange...
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

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

PostPosted: Tue Sep 14, 2004 7:29 am     Reply with quote

Joan -

You have Hypertermial set for 9600,8,n,1 and no handshake, right?
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Joan



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Tue Sep 14, 2004 12:32 pm     Reply with quote

Hi all:
I found the problem. When I load the hex file throught CCS Compiler it enables everytime an option called DEBUG. If it is enabled PIC doesn't works, so I take care continuously that this option must be disabled. So it is a problem of my programmer software not a CCS Compiler problem, so excuseme for you time lost ...
Program works fine now when programmer software it settend correctly (Config Bits).
Best Regards;
Joan.
_________________
I Came. I Saw. I Won.
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