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

18F24K40 & handle of rs232_errors

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



Joined: 09 Feb 2005
Posts: 43

View user's profile Send private message

18F24K40 & handle of rs232_errors
PostPosted: Thu Feb 22, 2018 3:00 am     Reply with quote

I have used the 18F24K40 with compiler version 5.076. My code is very simple:
Code:

#include <18F24K40.h>

#FUSES NOWDT                    //No Watch Dog Timer

#use delay(clock=64MHz,crystal=16MHz)
#use rs232(baud=9600,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1,enable=PIN_C5,errors)

#bit x=rs232_errors.0

void main()
{

   while(TRUE)
   {
      //TODO: User Code
   }

}

Compiler give error message "undefined identifier" for rs232_errors.

But, if I change the microcontroller with same code (#include <18F24K20.h> instead of #include <18F24K40.h>), there is no error message from compiler.

What's the wrong?

So, I want to use Hardware Uart with 18f24k40 with control the parity error.
How can I do with this MCU?
sraiderk



Joined: 09 Feb 2005
Posts: 43

View user's profile Send private message

Re: 18F24K40 & handle of rs232_errors
PostPosted: Thu Feb 22, 2018 5:17 am     Reply with quote

sraiderk wrote:
I have used the 18F24K40 with compiler version 5.076. My code is very simple:

#include <18F24K40.h>

#FUSES NOWDT //No Watch Dog Timer

#use delay(clock=64MHz,crystal=16MHz)
#use rs232(baud=9600,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1,enable=PIN_C5,errors)

#bit x=rs232_errors.0

void main()
{

while(TRUE)
{
//TODO: User Code
}

}

compiler give error message "undefined identifier" for rs232_errors.

But, if I change the microcontroller with same code (#include <18F24K20.h> instead of #include <18F24K40.h>), there is no error message from compiler.

What's the wrong?

So, I want to use Hardware Uart with 18f24k40 with control the parity error.
How can I do with this MCU?


The other solution using the RC1STA register. Bi 0 that has a parity bit, isn't it? From there, I will write parity control algorithm with comparing to RC1STA.0 and parity control algorithm.
Ttelmah



Joined: 11 Mar 2010
Posts: 13758

View user's profile Send private message

PostPosted: Thu Feb 22, 2018 9:09 am     Reply with quote

Why not just use 9bit mode?.

You can tell the #USE to give you long data (16bit values to/from the UART), and then the parity bit is the 9th bit. Much easier.
Ttelmah



Joined: 11 Mar 2010
Posts: 13758

View user's profile Send private message

PostPosted: Thu Feb 22, 2018 9:30 am     Reply with quote

I realise the reason your code is not working. You are not using the UART....

On the K40, the UART is a PPS peripheral (means it can be moved to other pins). Look at the 'sticky' at the top of the forum for how to use #PIN_SELECT.

On a PPS peripheral, there is no 'default' operation. You _must_ select the peripheral.

Code:

#PIN_SELECT U1TX=PIN_C6
#PIN_SELECT U1RX=PIN_C7

#use rs232(baud=9600,parity=E,UART1,bits=8,stream=PORT1,enable=PIN_C5,errors)
sraiderk



Joined: 09 Feb 2005
Posts: 43

View user's profile Send private message

PostPosted: Fri Feb 23, 2018 12:52 am     Reply with quote

It's OK now. Ttelmah, thank you for your help...
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