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

PIC24, 3 serial ports

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



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

PIC24, 3 serial ports
PostPosted: Thu Apr 28, 2011 8:13 am     Reply with quote

Crystal 20Mhz
Compiler 4.119
24FJ128GA106

I am using all 3 of the hardware serial ports and a fourth software serial port. At top of my program, all are defined as shown:

Code:

#pin_select U1TX=PIN_F3//use this for gps data to gps receiver #pin_select U1RX=PIN_F2
#pin_select U3TX=PIN_G8
#pin_select U3RX=PIN_G7
#use rs232(uart1,baud=38400,parity=N,bits=8,ERRORS,stream = uar1)
#use rs232(uart2,baud=9600,parity=N,bits=8,ERRORS,stream = uar2)
#use rs232(uart3,baud=38400,parity=N,bits=8,ERRORS,stream = uar3)
#use rs232(baud=9600,parity=N,bits=8,ERRORS,stream = uar4,force_sw,xmit=PIN_b8,rcv=PIN_b9)

All are working fine, all interrupts work as expected.

I want the user to select a function where I reroute the serial data from the software port (uar4) to the hardware port (uar3) but I don't want any baud rates involved, I just want to bit-bang in a tight loop:

Code:

   if (routebase){
      clrlcd();
      printf(lcd_putc,"\tROUTE SERIAL TO BASE");
      disable_interrupts(INTR_GLOBAL);
      output_low(move);
      output_low(steer1);
      output_low(steer2);
   }

   if (routebase){
      while(1){
         if (!input(key1)) {
            enable_interrupts(INTR_GLOBAL);
            routebase = 0;
            goto sc1;
        }
        output_toggle(safety);
        output_bit(pin_g8,input(pin_b9));
        output_bit(pin_b8,input(pin_g7));
      }
   }
sc1:
//rest of code


Is the fact I already have my hardware ports defined causing this not to work? Can I change IO pins that are assigned to a #use rs232 function?
ljbeng



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

PostPosted: Thu Apr 28, 2011 8:51 am     Reply with quote

I should add, if I write a program that does not defiine the serial ports and only has these lines:
Code:

      while(1){
        output_bit(pin_g8,input(pin_b9));
        output_bit(pin_b8,input(pin_g7));
      }

The program works and I get the serial redirection I want. The REAL program with serial ports defined in #use rs232, does not work.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Apr 28, 2011 8:57 am     Reply with quote

Defining an output #pin_select function disconnect the pin from it's default IO function. Consult the Microchip processor datasheet for details.

Peripheral pin selects can be set dynamically by writing to the respective SFRs, but this option isn't provided by CCS C built-in functions.
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