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

UART XMIT and RCV?
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
Ttelmah
Guest







PostPosted: Fri Oct 27, 2006 5:19 am     Reply with quote

Before trying anything else, have you tried another PIC?. One possibility, is that the pin is damaged on your chip.
I tried with 3.249, and it behaved as 'expected', however I don't remember their being much if any change round this area in the 3.24x versions, so this is unlikely to be the problem. Try the test code, with another chip, and with the pin not connected to anything (you are sure you are testing the right pin?), and if it still behaves stupidly, I'll try an earlier compiler version and see what happens.

Best Wishes
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PostPosted: Mon Feb 26, 2007 4:23 pm     Reply with quote

Hi,

I've the same problem with 16F88 and compiler version 3.242.

I made as you suggest in my code but pin B5 is always high. it is output and it is connected to the same component connected to pin B3, that is a mosfet driver. and PIN B3 works correctly instead pin B5 always H.

If i try to change xmit pin to anyother pin, pin B5 starts going low. But unfortunately device doesn't work good, and uart doesn't receive good data as it did with pin_b5 as xmit.

there could be any solution??


Thanks
Mattr0



Joined: 27 Mar 2005
Posts: 30

View user's profile Send private message Visit poster's website

PostPosted: Mon Feb 26, 2007 8:03 pm     Reply with quote

I do believe that this is impossible. When you enable the uart it enables both the TX uart and RX uart. and it is an inverted drive hence why the pin is high. my suggestion is use a different pin. I don't think you will ever find a solution to this other than use a different pin or don't use the uart.

Have you referred to the data sheet for this part to see if it possible to enable only the receive uart?
Ttelmah
Guest







PostPosted: Tue Feb 27, 2007 3:22 am     Reply with quote

fuzzy wrote:
Hi,

I've the same problem with 16F88 and compiler version 3.242.

I made as you suggest in my code but pin B5 is always high. it is output and it is connected to the same component connected to pin B3, that is a mosfet driver. and PIN B3 works correctly instead pin B5 always H.

If i try to change xmit pin to anyother pin, pin B5 starts going low. But unfortunately device doesn't work good, and uart doesn't receive good data as it did with pin_b5 as xmit.

there could be any solution??


Thanks


Yes, there is a simple solution, and I have posted it in the past.
For your chip, setup as follows:
Code:

#use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=8)

#byte TXSTA=0x98H
#bit TXEN=TXSTA.5

Then early in the main, add the line 'TXEN=0;'
Ths simply turns off the hardware transmit component. So long as you don't use any transmit functions (putc etc.), on the UART, the transmit pin then becomes available to use.

Best Wishes
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PostPosted: Tue Feb 27, 2007 6:29 am     Reply with quote

Hi,

I tryed the code you suggested me, but it's the same. Pin B5 continue to be H. no way to put it L. I saw I can put it L only using Software UART. Using FORCE_SW statement in #USE_RS232.

But in that case i can't receive correctly my data. I can't understand why Using HW UART my receiver works and using Software Uart it doesn't receive.

on the contrary Using HW uart PIN B5 doesn't work as output but using SW one, PIN B5 works correctly as output.

I'd like to solve this problem. If not possible do you think i can use pin_b5 as input better than output?

Thanks a lot
Ttelmah
Guest







PostPosted: Tue Feb 27, 2007 9:00 am     Reply with quote

I have just stuck it into a chip, and it runs fine...
Have B5, merrily toggling away, and a longer delay, when a character arrives.
Code:

#include "setup.h" //set clock rate an fuses here
#use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=8)
#byte TXSTA=0x98
#bit TXEN=TXSTA.5

void main() {
   int8 dummy;
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(VREF_LOW|-2);
   setup_oscillator(False);
   TXEN=0;
   while (true) {
      if (kbhit()) {
         dummy=getc();
      }
      output_toggle(PIN_B5);
      if (dummy) {
         delay_us(100);
         dummy=0;
      }
      delay_us(10);
   }
}


Best Wishes
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PostPosted: Tue Feb 27, 2007 10:08 am     Reply with quote

NoWAY, I'm giving up.

with your code it doesn't work. PIN be can be controlled only forcing SW UART. but unfortunately receiver doesn't receive correct data with sw uart and device doesn't work.

i hope PIB B5 works better as input.
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