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

Undefined identifier TXSTAbits , RCSTAbits

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



Joined: 21 Jul 2023
Posts: 3

View user's profile Send private message

Undefined identifier TXSTAbits , RCSTAbits
PostPosted: Sat Jul 22, 2023 4:03 am     Reply with quote

How to solve this error (16F685)?
Code:

// Function to initialize UART module
void UART_Init() {
    output_low(PIN_C7);  // TX pin as output
    output_high(PIN_C6); // RX pin as input
   
    TXSTAbits.TXEN = 1;  // Enable transmitter
    RCSTAbits.CREN = 1;  // Enable receiver
    TXSTAbits.BRGH = 1;  // High-speed mode

}


Thank you
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jul 22, 2023 5:09 am     Reply with quote

curious am i , so downloaded the datasheet.

According to Table3, on page 4, that PIC does NOT have a UART. That explains the error message.
The version 689 and 690 do have the USART though.


BTW, these...comments are wrong.

output_low(PIN_C7); // TX pin as output

//configures the pin as an output and sends a 'zero' to that pin


output_high(PIN_C6); // RX pin as input

//configures the pin as an output and sends a 'one' to that pin
sit



Joined: 21 Jul 2023
Posts: 3

View user's profile Send private message

PostPosted: Sat Jul 22, 2023 5:50 am     Reply with quote

temtronic wrote:
curious am i , so downloaded the datasheet.

According to Table3, on page 4, that PIC does NOT have a UART. That explains the error message.
The version 689 and 690 do have the USART though.



Thank You

Is it possible to use 16F685 to interface with PZEM-004T AC communication module?

https://innovatorsguru.com/wp-content/uploads/2019/06/PZEM-004T-V3.0-Datasheet-User-Manual.pdf
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jul 22, 2023 10:32 am     Reply with quote

Yes, it should be possible, though you'll need to use a 'software' UART. The device is NOT 'RS-485', rather just normal TTL, so you connect PIC TX pin to module RX pin, and PIC RX pin to modules TX pin.
You'll also have to create the 'CRC', that they talk about..it's the last 2 bytes the PIC will send.
Ttelmah



Joined: 11 Mar 2010
Posts: 19536

View user's profile Send private message

PostPosted: Sat Jul 22, 2023 11:38 pm     Reply with quote

It'll be hard though. The whole approach will need to be re-thought, since
receive on a software UART has no buffering and requires you to be
waiting for the data. It can probably be done, but will need a lot of
reprogramming. I must admit the idea of handling serial MODBUS without
a serial interrupt is going to be pretty scary programming.
sit



Joined: 21 Jul 2023
Posts: 3

View user's profile Send private message

PostPosted: Sun Jul 23, 2023 6:03 am     Reply with quote

Ttelmah wrote:
It'll be hard though. The whole approach will need to be re-thought, since
receive on a software UART has no buffering and requires you to be
waiting for the data. It can probably be done, but will need a lot of
reprogramming. I must admit the idea of handling serial MODBUS without
a serial interrupt is going to be pretty scary programming.


By using the PIC 16F685 microcontroller to interface with the PZEM-004T module and requesting data only when necessary, I can avoid the continuous need for serial communication and data reading, which eliminates the need for complex buffering mechanisms and real-time handling. This approach allows I to have more control over when data is retrieved, making it easier to handle the communication process and ensuring that I ready to receive and process the data when it is requested.
Do you agree?
Best regard
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jul 23, 2023 7:37 am     Reply with quote

Provided you use one of the 10 pins that are 'IOC', you can create a reliable software UART. 'Old school', done before UARTs were actually available.
I'm pretty sure someone here , or on the Internet, has cut code......
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