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

#use rs232(...enable=PIN_J7...)

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



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

#use rs232(...enable=PIN_J7...)
PostPosted: Tue Mar 21, 2006 11:37 am     Reply with quote

I am using PCWH 3.245 with an 18LF8622.

I used the following line in my code:

Code:

      #use rs232(baud=ARINC_BAUD, xmit=PIN_G1, rcv=PIN_G2, ERRORS, parity=O, bits=8, enable=PIN_J7)


J7 never seems to go high when I transmit.

I put in code to deliberately toggle it just to prove that I could do it and that works fine.

I see the serial data coming out of the G1, so I know the serial port is working.

Is there something I don't know?
_________________
-Pete
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 21, 2006 12:56 pm     Reply with quote

Port J is configured for use with the External Memory Interface upon
power-up reset. CCS doesn't change it to digital i/o for you.
You need to do it with a line of code.

See this thread for an example:
http://www.ccsinfo.com/forum/viewtopic.php?t=23622
pfournier



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

PostPosted: Tue Mar 21, 2006 1:14 pm     Reply with quote

I did that already. Note the place where I said:
Quote:

I put in code to deliberately toggle it just to prove that I could do it and that works fine.

_________________
-Pete
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 21, 2006 1:55 pm     Reply with quote

I made the test program shown below and looked at the .LST file.
The generated code looks OK. This was with PCH vs. 3.245.
Code:

#include <18F8622.H>
#fuses XT, NOWDT,  NOPROTECT, BROWNOUT, PUT, NOLVP   
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, ERRORS, parity=O, bits=8, enable=PIN_J7)

#byte MEMCON = 0xF9C
#bit  EBDIS = MEMCON.7

//==========================
void main()
{

EBDIS = 1;  // Port J = digital i/o

while(1)
  {
   putc(0x55);
   delay_ms(1);
  }

}


See the code below. It appears to toggle the Enable pin
high and low properly.
Code:

... #use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2,
ERRORS, parity=O, bits=8, enable=PIN_J7) 

00004:  BCF    F9A.7  // TRISJ.7 = output
00006:  BSF    F91.7  // LATJ.7 = 1  (set enable high)

00008:  MOVLW  08     // Calculate odd parity
0000A:  MOVWF  01
0000C:  CLRF   07
0000E:  INCF   07,F
00010:  MOVFF  06,00
00014:  MOVF   00,W
00016:  XORWF  07,F
00018:  RRCF   00,F
0001A:  DECFSZ 01,F
0001C:  BRA    0014

0001E:  BTFSS  FA4.4   // Wait until transmitter is ready
00020:  BRA    001E

00022:  MOVLW  FE      // Set TX9D bit = odd parity     
00024:  ANDWF  F6C,F
00026:  BTFSC  07.0
00028:  BSF    F6C.0

0002A:  MOVFF  06,F6D  // Put byte into transmitter
0002E:  NOP   

00030:  BCF    F9A.7   // TRISJ.7 = output
00032:  BSF    F91.7   // LATJ.7 = 1  (Set enable high)

00034:  BTFSS  F6C.1   // Wait until byte is transmitted
00036:  BRA    0034

00038:  BCF    F9A.7   // TRISJ.7 = output
0003A:  BCF    F91.7   // LATJ.7 = 0  (Set enable low)
0003C:  GOTO   009A (RETURN)
pfournier



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

PostPosted: Tue Mar 21, 2006 3:17 pm     Reply with quote

This looks interesting, you've shown me where to look for this. I'll be back
_________________
-Pete
pfournier



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

PostPosted: Tue Mar 21, 2006 4:36 pm     Reply with quote

Ok,

I figured it out.
The setting and resetting of the enable line is done within the putc().
I thought it was done at a MUCH lower level.

I handle the transmitting in an interrupt with a fairly large circular buffer so I will fill the buffer turn on the enable line and leave it on until the buffer is empty.

Interestingly I just realized as I looked at the code that parity is also calculated in the putc and is not done in hardware....looks like I have to do that myself!

Thanks for the insight!
_________________
-Pete
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