|
|
View previous topic :: View next topic |
Author |
Message |
sraiderk
Joined: 09 Feb 2005 Posts: 48
|
18F24K40 & handle of rs232_errors |
Posted: Thu Feb 22, 2018 3:00 am |
|
|
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: 48
|
Re: 18F24K40 & handle of rs232_errors |
Posted: Thu Feb 22, 2018 5:17 am |
|
|
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: 19510
|
|
Posted: Thu Feb 22, 2018 9:09 am |
|
|
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: 19510
|
|
Posted: Thu Feb 22, 2018 9:30 am |
|
|
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: 48
|
|
Posted: Fri Feb 23, 2018 12:52 am |
|
|
It's OK now. Ttelmah, thank you for your help... |
|
|
|
|
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
|