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

How to activate a hardware UART on PIC24FJ64GA004

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



Joined: 10 May 2012
Posts: 3

View user's profile Send private message

How to activate a hardware UART on PIC24FJ64GA004
PostPosted: Tue Aug 07, 2012 7:26 am     Reply with quote

Hello

PIC24FJ64GA004
version 4.130
PIC24 -> PICkit2 UART Tool -> PC
Code:

#INCLUDE <24FJ64GA004.h>
#INCLUDE <string.h>
#INCLUDE <stdlib.h>
 
#FUSES NOWDT                   
#FUSES NOJTAG                   
#FUSES NOPROTECT               
#FUSES NOWRT                   
#FUSES NODEBUG                 
#FUSES IOL1WAY                 
#FUSES NOWINDIS                 
#FUSES WPOSTS16               
#FUSES IESO                     
#FUSES FRC_PLL//_PS//                   
#FUSES NOCKSFSM                 
#FUSES NOOSCIO                 
#FUSES HS                                 

#use delay(clock=32000000)
//***************************************************************
#Pin_select U1TX=PIN_B13
#Pin_select U1RX=PIN_B12
#use rs232(baud=9600,ERRORS)
//***************************************************************
#INT_RDA
void serial_isr()
{
unsigned char i;
i=getc();
putc(i);
}
//***************************************************************
void main()
{
setup_oscillator(OSC_INTERNAL);
delay_ms(2000);
OUTPUT_high(PIN_A0);
CLEAR_INTERRUPT(INT_RDA);
ENABLE_INTERRUPTS(INT_RDA);
ENABLE_INTERRUPTS(INTR_GLOBAL);

while(true);
}

I need to use interrupt received by the UART, but it does not work. It is only software UART, UART hardware is not turned on. How to activate and to use hardware UART interrupt?
(This code works with interrupt on the PIC18f2320).

I have connected good. This code works
Code:

void main()
{
unsigned char i;
setup_oscillator(OSC_INTERNAL);
OUTPUT_high(PIN_A0);

while(true)
{
   i=getc();
   putc(i);
}
}

Excuse my English. Use a compiler.
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Tue Aug 07, 2012 11:22 am     Reply with quote

Code:

#Pin_select U1TX=PIN_B13
#Pin_select U1RX=PIN_B12
#use rs232(UART1,baud=9600,ERRORS)


Best Wishes
milops3



Joined: 10 May 2012
Posts: 3

View user's profile Send private message

PostPosted: Wed Aug 08, 2012 2:31 am     Reply with quote

Yes, work it
I used the "STREAM=UART1 "
in help is written
Quote:
UART1 Sets the XMIT= and RCV= to the chips first hardware UART
I understood it wrong

thank you very much
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Wed Aug 08, 2012 4:57 am     Reply with quote

It is slightly confusing, on chips with peripheral remapping like this.

'UART1', basically tells the #use RS232 to talk to the UART hardware. Normally (on chips with fixed I/O pins), you can get the same result by selecting TX= and RX= with the pins matching the fixed peripheral pins.
On the chips with re-mappable pins, you have to do the two separate operations, tell #use RS232, to talk to the UART hardware (hence UART1, or UART2), and then use #pin select to actually specify what pins this hardware is to use.

Best Wishes
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