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

PIC18LF27K40: rs232- Rx working, TX never sends

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



Joined: 10 Mar 2022
Posts: 2

View user's profile Send private message AIM Address

PIC18LF27K40: rs232- Rx working, TX never sends
PostPosted: Thu Mar 10, 2022 4:23 pm     Reply with quote

Hello, I'm using a pic18lf27k40. The issue is I have setup rs232 the following pins and am able to receive a byte and do a long or short flash, but the response byte is never sent. If anyone has insight it would be greatly appreciated.

NOTE: I cannot change the pins b/c boards are already in production. These pins are in use for i2c but we want to be able to switch to uart and add a bootloader to all new boards

Code:
#define IO_RX  PIN_C3   
   #define IO_TX  PIN_C4
   #use rs232(STREAM=UART_BOOT,BAUD=9600,xmit=PIN_C5,rcv=IO_RX,  ERRORS, DISABLE_INTS, FORCE_SW)
   
   uInt8 data,st = 0;
   while(1){
         data = 0;//fgetc(UART_BOOT);
         switch(data){
            case 0xAA:
               fputc(data+1,UART_BOOT);
               //fputc(data + 1, UART_BOOT);
               LedPulse(100);
               break;
            case 0xDD:
               fputc(data+1,UART_BOOT);
               //fputc(data + 1, UART_BOOT);
               LedPulse(500);
               break;
            default:
               //#use rs232(STREAM=UART_BOOT,BAUD=115200,xmit=IO_TX,rcv=IO_RX,  ERRORS, DISABLE_INTS, FORCE_SW)
               fputc(0xEE,UART_BOOT);
              //st ? LedSetPwm(100) : LedSetPwm(0);
              LedSetPwm(st ?100:0);
               st = !st;
               //output_toggle(PIN_C4);
               //printf(UART_BOOT, "%d",data+1);
               //fputc(0x01, UART_BOOT);
               break;
         }
         delay_ms(50);
      }
PCM programmer



Joined: 06 Sep 2003
Posts: 21658

View user's profile Send private message

PostPosted: Thu Mar 10, 2022 6:32 pm     Reply with quote

Where are your #pin_select statements ?
Ttelmah



Joined: 11 Mar 2010
Posts: 18060

View user's profile Send private message

PostPosted: Fri Mar 11, 2022 1:40 am     Reply with quote

If you look, he is using software RS232.
However he talks about using a UART....

However there seems to be a likely problem on what pin is actually used.
He has an 'IO_TX' pin defined as C4, but actually sends on C5. Which one
is right, and is being tested?.
On the C4 pin, if the PPS is setup for this to be an I2C pin, he needs to
turn this off before he can use it for normal I/O.

#PIN_SELECT NULL=PIN_C4

Otherwise the peripheral always has priority over normal I/O....
asczarnecki



Joined: 10 Mar 2022
Posts: 2

View user's profile Send private message AIM Address

Solved!
PostPosted: Fri Mar 11, 2022 9:28 am     Reply with quote

Thank you for your response! The pin change from C4 -> C5 was for testing with the scope on a more accessible pin.

The solution did come from selecting the pins to null before initializing rs232 has fixed the issue!

Code:

pin_select("NULL", PIN_C3);
pin_select("NULL", PIN_C4);



This other post you responded to had some helpful stuff too.

http://www.ccsinfo.com/forum/viewtopic.php?t=57581

Thanks again!
Ttelmah



Joined: 11 Mar 2010
Posts: 18060

View user's profile Send private message

PostPosted: Fri Mar 11, 2022 10:58 am     Reply with quote

Good.
It is an important point, that on most of the chips supporting PPS, the
'peripheral' overrides the normal pin operation, so if a pin is setup with
PPS for one peripheral, to use it for anything else you need to either
remove the PPS assignment, or make a new assignment.
Glad you have it working now.
I'd have expected you to actually make new assignments to a UART,
if you intend to use this for a bootloader.
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