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

TX problem in PIC18F46k22

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



Joined: 25 Sep 2013
Posts: 18

View user's profile Send private message

TX problem in PIC18F46k22
PostPosted: Thu Sep 26, 2013 1:07 am     Reply with quote

MY Compiler's version is 4.108.

When sending a character to PC via Only TX of UART1, PC is receiving character from PIC8F46K22. BUT when sending a character to PC via TX of both UART1 and UART2, PIC is shut down and freezing.
I want two UART.
Help me.

Code:

#include <18f46k22.h>
#device *=16 adc=10
//#device pass_strings=in_ram
#FUSES H4   



#use delay(internal=16Mhz,clock=64Mhz,RESTART_WDT,clock_out))   


#use rs232(UART1,baud=19200,stop=1,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,restart_WDT,errors,stream=SER1)
#use rs232(UART2,baud=19200,stop=1,parity=N,xmit=PIN_D6,rcv=PIN_D7,bits=8,restart_WDT,errors,stream=SER2)

#ZERO_RAM

#include <stdio.h>



#use fast_io(a)     
#use fast_io(b)     
#use fast_io(c)     



int32 gtemp1=1234567;
long int Delay_time=1000;
int Serial_1=0;
int Serial_2=0;
int Rx1Flag=0;
char RecvChar=null;



#int_rda
void rda_isr(void)
{
    RecvChar = getc(); 
    Delay_time = 100;
    Rx1Flag = 1;

}


#int_ext
Void ext_isr(){
         
         if(Delay_time==100)
         Delay_time=1000;
         else
         Delay_time=100;
}


void main()

   SET_TRIS_A(0b00000000);   
   SET_TRIS_B(0b11000001);   
   SET_TRIS_C(0b11000000);   
   SET_TRIS_C(0b11000000);
   //   Port_B_Pullups(TRUE);
   
   
   

   enable_interrupts(INT_EXT);
 
   disable_interrupts(INT_RB);
   disable_interrupts(INT_AD);     
   enable_interrupts(INT_RDA);
   disable_interrupts(INT_TBE);
 

   disable_interrupts(INT_CCP1);     
   disable_interrupts(INT_CCP2);     

   disable_interrupts(INT_EEPROM);
   enable_interrupts(GLOBAL);


 
 
   
   while(true){

#byte ANSELA = 0xF38
#byte ANSELB = 0xF39
#byte ANSELC = 0xF3A
#byte ANSELD = 0xF3B
#byte ANSELE = 0xF3C

ANSELA = 0;
ANSELB = 0;
ANSELC = 0;
ANSELD = 0;
ANSELE = 0;

      delay_ms(500);
      gtemp1+=1;

      fprintf(SER1,"UART1=%lu \r\n", gtemp1);
      fputs("----------------",SER1);
     fprintf(SER2,"UART2=%lu \r\n", gtemp1);
     fputs("----------------",SER2);
   
      if(Rx1Flag==1)   
         {
             fprintf(SER1,"%c \r\n",RecvChar);
              Rx1Flag   = 0;
         }
               
     


      output_bit(pin_b1,1);   
   //    led=0b000000010;
      delay_ms(Delay_time);         
      output_bit(pin_b1,0);
   //   led=0b00000000;
      delay_ms(Delay_time);         
   
//      Delay_time +=50;
   }
}
hwryu



Joined: 25 Sep 2013
Posts: 18

View user's profile Send private message

Re: TX problem in PIC18F46k22
PostPosted: Thu Sep 26, 2013 1:28 am     Reply with quote

I tested it again. I find that even when using only UART2, the problem happens.
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