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

#pin_select problem on PIC18F47J13

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



Joined: 02 Aug 2015
Posts: 16
Location: Australia

View user's profile Send private message

#pin_select problem on PIC18F47J13
PostPosted: Sun Apr 26, 2020 1:06 am     Reply with quote

I am having problems getting the hardware USART working with #pin_select.
and yes I did read the sticky note but am still at a loss what my problem is.

Compiler 5.071
If I compile as listed I get an Error 100 ....:USE parameter value is out of range Not a number: TX2
If I flip the PIN definitions it compiles but a soft driver and no interrupt which is my aim.
If somebody could help I would appreciate it.

Code:

#include <18F47J13.h>
#device ADC=12

#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES SOSC_HIGH                //High-power SOSC circuit is selected
#FUSES NOCLOCKOUT               //I/O function on OSC2
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES DSWDTOSC_INT             //DSWDT uses INTRC as reference clock
#FUSES RTCOSC_T1                //RTCC uses Secondary Oscillator as reference source
#FUSES DSBOR                    //BOR enabled in Deep Sleep
#FUSES NODSWDT                  //Deep Sleep Watchdog Timer disabled
#FUSES IOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES ADC12                    //ADC is 12-bits
#FUSES MSSPMSK7                 //MSSP uses 7 bit Masking mode
#FUSES WPFP                     //Write/Erase Protect Page Start/End Location, set to last page or use WPFP=x to set page
#FUSES NOWPCFG                  //Configuration Words page is not erase/write-protected
#FUSES WPDIS                    //All Flash memory may be erased or written
#FUSES WPEND                    //Flash pages WPFP to Configuration Words page are write/erase protected



//!
#use delay(internal=32MHz)


#define Sensor_PWR   PIN_B4 



#pin_select RX2   =  PIN_C1 
#pin_select TX2   =  PIN_C2
//!#define RX2   PIN_C1 
//!#define TX2   PIN_C2


#use rs232(baud = 9600, parity = N, xmit = TX2, rcv = RX2, bits = 8, stream = BT)   ///Changed


#INT_RDA2
void  RDA2_isr(void) {
   // Serial port for Bluetooth Module
   int8 c = getc(BT);
   putc(c,BT);


void main(){

   enable_interrupts(INT_RDA);
   enable_interrupts(INT_RDA2);
   enable_interrupts(GLOBAL);
   while(TRUE){
   fprintf(BT,"Main loop\n\r");
   
   output_toggle(Sensor_PWR);
   delay_ms(500);
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 26, 2020 3:13 am     Reply with quote

The sticky post on #pin_select at the top of the post list shows how to do it:
Code:

#pin_select U2RX=PIN_C1
#pin_select U2TX=PIN_C2
#use rs232(UART2, BAUD=9600, ERRORS)
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sun Apr 26, 2020 3:39 am     Reply with quote

and, the place to look is the header file for your chip. This a couple of
paragraphs down, lists all the PIN_SELECT 'pin names' that can be used.
HaveAchat



Joined: 02 Aug 2015
Posts: 16
Location: Australia

View user's profile Send private message

PostPosted: Sun Apr 26, 2020 4:05 am     Reply with quote

Hmmmm that was easy!Embarassed
In my defence I studied the device file and saw TX2 and RX2 and thought they were the USART designation....
I must of had a boys look and totally missed the U2TX and U2RX for the past week, what can I say.

Another problem is I did not use the default #use rs232(UART2, definition. It doesn't work any other way. Two point of ignorance!

So, a question to help my understanding please?

What does TX2 and RX2 refer to?

Once again many thanks for the assistance.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sun Apr 26, 2020 7:20 am     Reply with quote

Yes, that is a case of CCS choosing to use one 'part' of the MicroChip name.
TX2, works for synchronous transmit, and RX2 for synchronous receive,
but not for the standard async TX/RX. Really should be DT2/RX2.
Designed totally to confuse... Sad
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