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

Trouble while sending data from PC to PIC16F887 via MAX232

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



Joined: 08 Jan 2024
Posts: 1
Location: Rio de Janeiro, Brazil

View user's profile Send private message

Trouble while sending data from PC to PIC16F887 via MAX232
PostPosted: Mon Jan 08, 2024 6:29 pm     Reply with quote

Hello everyone, sorry for eventually bad english lol

I'm tryna simulate an Proteus circuit that could send data from any PC with RS232 interface to PIC16F887, which chip uses TTL language. I did the data flow from PIC to PC, but`s not working vice-versa. In simulation, I put two Virtual Terminal, each one in both sides of communication (TTL and RS-232), using the MAX232 chip, to read the data flow. The one which represents the receiving data is set to Inverted mode because of the inverted data in the RS232 side of MAX232. Each command sent from any sides should return a message of acknowlegdement (ACK).

I saw many examples of creating the circuit in Proteus, including capacitors` values, they are the same way, so i think the problem should be any configuration from the code, or even the simulator.

I'm working with an Pascal (MikroPascal) compiler, but i know that many people working with PIC uses C, so I kindly accept answers with any code language at least to confirm is the circuit is properly assembled.

the section of the circuit of interest in Proteus
https://ibb.co/0tCmQkj

circuit working only from PIC to PC
https://ibb.co/NSqgyNw

thank you for the attention and have a nice day Smile[/url]
_________________
greetings from Brazil
temtronic



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

View user's profile Send private message

PostPosted: Mon Jan 08, 2024 7:08 pm     Reply with quote

The PIC's UART only has a 2 character buffer,so if your PC sends more characters before the PIC can process them ( read the UART buffer ) then the UART will 'overrun' and 'locks up', 'freezes'.
In CCS C , you add 'ERRORS' to the options when setting up the 'RS232' serial communications. This tells the compiler to add code to handle the 'overrun' condition.
Normally with any serial communications, you receive data into a 'buffer' using an Interrupt Service Routine(ISR). Whenever a character is sent to the PIC, the ISR 'sees' this action , reads the UART incoming data,saves the data in a circular buffer and sets a 'flag'. Your 'main' program then 'sees' this flag and read the data from the circular buffer and does 'something with it(say display on LCD module).
Normally the circular buffer will be 2x longer than the 'data stream' you expect to get. If you expect 'Hello PIC' from the PC, then you'd create a buffer of 20 characters long. The longer the buffer the more time you have to process the data.

Hopefully this will help you.....
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Feb 16, 2024 1:59 pm     Reply with quote

Therein lies the problem with using Proteus and why we say NOT to use it...
_________________
Google and Forum Search are some of your best tools!!!!
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