Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Software Usart

Status
Not open for further replies.
Hello Ian,

I am using internal 4mhz clock .

Found with simple led method the interrupt is not getting triggered when data received at RX pin.

any idea ?

latest progress ..... tried with 4mhz resonator with HS config bit ......still no luck
 
Last edited:
When debugging serial, you really need to clear the input buffer before receiving a new packet or the '#' will always be there even if there were errors.

A simple while loop to clear the input buffer at the end of a successful transmission is needed..
 
ok i am a little confused here

my code for receving and storing

Code:
On Interrupt
Save System
    If RCSTA.OERR = True Then  'any error reboot serial module..
        RCSTA.CREN = 0
        RCSTA.CREN = 1
        Goto fin
    Endif
    serdata = RCREG  '; get character(reading clears the RCIF)
   
    If serdata > 0 Then
     
                data(j) = serdata  'store data in buffer
                    j = j + 1
                If j = 12 Then
                    j = 0
                    outptr = True
                Endif
    Endif

fin:
    Resume

You want me to clear serdata or data ? cause data is getting cleared after the array buffer has been processed using

For k = 0 To 12 Step 1 'clear buffer
data(k) = 0x00
Next k

now i tried the same software on another MCU 16f690 had brand new ones around.

one 690 works and the other 690 does not.

After power up. The first time data is sent to the rx pin the MCU halts for say a good 3secs i know this cause there is a status led blinking every 0.5sec
which does not blink.

Then after that 3sec of halt the Status led starts to blink again and any data sent after this is accepted by the Chip.

Same issue was there with the working 16f628A also, the second 690 when the data is sent first time same halt but does not resume after 3 sec same as other 628a's

very confusing this is ..... :( please help or advice.

thanx in advance.

mastero
 
ok update :

The system hangs after reading the first byte.

i taught

serdata = RCREG

will clear the RCIF buffer and it is a read only as per DS 12.2.2

am i missing something here ??

cheers
mastero
 
Last edited:
Reading the RCREG clears the flag...

Sorry about the confusion about clearing the data buffer.... But as it wasn't included, I did't know it was there...

When I get some time tonight, I'll get one up and running as see what gives..
 
Ok thanx will to see what you come up with.

In osho simulator it works perfectly.

Very confusing.

Cheers
Mastero
 
solved ...

the issue was there was too many waitms in the code.....;)

make a sub for each and call it .....solves the problem for any one who walks my path...;)

thank you a million for all who helped.... specially ian :)

cheers
mastero
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top