Searching \ for 'PIC16F88 USART - can't recieve anything' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=usart
Search entire site for: 'PIC16F88 USART - can't recieve anything'.

Truncated match.
PICList Thread
'PIC16F88 USART - can't recieve anything'
2008\04\06@170810 by Ivan Petrushev

picon face
Hello,
I have problems recieving serial communication with PIC16F88. I'm
using PICC compiler for MPlab.
I have another PIC of the same series transmitting some stuff, and
that reciever PIC can't register any incomming signal.
This is the source file for the tranciever:
########################################
#include <pic.h>

void send(char letter) {

   while (!TRMT) {
       // Delay until sent
   }
   TXREG = letter;
}

void main(void) {
        char x;
       OSCCON = 112;   //4Mhz
       TRISB = 4;      //RB2 - in, RB5 - out
       PORTB = 0;
       TXSTA = 32;     //async mode
       RCSTA = 128;    //usart enable
       SPBRG = 2;      //19.2 kbps

       x = 0;
               TXREG = x;
       RB0 = 0;
       while(1) {
                               x++;
                               send(x);

               RB0 = 0;
       }

}
########################################
This is working, becouse I can see a signal on the wire between two PICs.
Here is the code for the reciever. I've made several kinds of debug
info - writing recieved input to data eeprom, and pulling high some of
the PORTA bits:
########################################
#include <pic.h>
char ee_count = 0;
char tmp;

void main(void) {
       OSCCON = 112;   //4Mhz
//I was not sure if I will need interrupts, and some other version of
the same code tried to use interrupts, but it didn't happen neither
       GIE = 1;
       PEIE = 1;
       RCIE = 1;
       ANSEL = 0;
       TRISA = 0;
       TRISB = 4;      //RB2 - in, RB5 - out
       PORTB = 0;
       TXSTA = 32;     //async mode
       RCSTA = 128;    //usart enable
       SPBRG = 2;      //19.2 kbps
       RA3 = 0;
       while(1) {
              RA3 = 1;
              if (RCIF){
                     RA0 = 1;
                     ee_count++; //write on which address in eeprom
                     EEADR = ee_count;
                     tmp = RCREG;
                     EEDATA = tmp;
                     EECON1 = 4;
//write eeprom - this is taken from the pic16 documentation and it is working
                     #asm
                             movlw 0x55
                             movwf 0x18d
                             movlw 0xAA
                             movwf 0x18d
                             bsf 0x18c,1
                     #endasm
                     while (EECON1 & 2){ //eeprom write finished
                     #asm
                              nop
                     #endasm
                     }
                    RA0 = 0;
              }// if RCIF
              RA3 = 0;
       } //main loop

}
########################################

2008\04\07@040336 by Ivan Petrushev

picon face
Hello, (did my previous attempt to post on the list failed?)
I have problems recieving serial communication with PIC16F88. I'm
using PICC compiler for MPlab.
I have another PIC of the same series transmitting some stuff, and
that reciever PIC can't register any incomming signal.
This is the source file for the tranciever:
########################################
#include <pic.h>

void send(char letter) {

   while (!TRMT) {
       // Delay until sent
   }
   TXREG = letter;
}

void main(void) {
        char x;
       OSCCON = 112;   //4Mhz
       TRISB = 4;      //RB2 - in, RB5 - out
       PORTB = 0;
       TXSTA = 32;     //async mode
       RCSTA = 128;    //usart enable
       SPBRG = 2;      //19.2 kbps

       x = 0;
               TXREG = x;
       RB0 = 0;
       while(1) {
                               x++;
                               send(x);

               RB0 = 0;
       }

}
########################################
This is working, becouse I can see a signal on the wire between two PICs.
Here is the code for the reciever. I've made several kinds of debug
info - writing recieved input to data eeprom, and pulling high some of
the PORTA bits:
########################################
#include <pic.h>
char ee_count = 0;
char tmp;

void main(void) {
       OSCCON = 112;   //4Mhz
//I was not sure if I will need interrupts, and some other version of
the same code tried to use interrupts, but it didn't happen neither
       GIE = 1;
       PEIE = 1;
       RCIE = 1;
       ANSEL = 0;
       TRISA = 0;
       TRISB = 4;      //RB2 - in, RB5 - out
       PORTB = 0;
       TXSTA = 32;     //async mode
       RCSTA = 128;    //usart enable
       SPBRG = 2;      //19.2 kbps
       RA3 = 0;
       while(1) {
              RA3 = 1;
              if (RCIF){
                     RA0 = 1;
                     ee_count++; //write on which address in eeprom
                     EEADR = ee_count;
                     tmp = RCREG;
                     EEDATA = tmp;
                     EECON1 = 4;
//write eeprom - this is taken from the pic16 documentation and it is working
                     #asm
                             movlw 0x55
                             movwf 0x18d
                             movlw 0xAA
                             movwf 0x18d
                             bsf 0x18c,1
                     #endasm
                     while (EECON1 & 2){ //eeprom write finished
                     #asm
                              nop
                     #endasm
                     }
                    RA0 = 0;
              }// if RCIF
              RA3 = 0;
       } //main loop

}
########################################

2008\04\07@044207 by Rikard Bosnjakovic

picon face
On 07/04/2008, Ivan Petrushev <spam_OUTivanatoraTakeThisOuTspamgmail.com> wrote:

> Hello, (did my previous attempt to post on the list failed?)

No.

--
- Rikard - http://bos.hack.org/cv/

2008\04\15@090645 by Mauricio Giovagnini

flavicon
face
Ivan Petrushev escribió:
{Quote hidden}

Hi, a little late. I hope is not too late.

You are not checking for any errors in the reception.  If
the RCSTA.OERR bit is set reception will be stopped until
CREN is cleared & set again.

Also, take into consideration that storing a byte in eeprom
can last about 4msec and that 1 byte being transmitted at
19200bps will delay close to 0.5msec





--
------------------------------
Mauricio Giovagnini (Maunix)
http://www.maunix.com.ar
Cordoba, Arg.
LinkedIn Profile: http://www.linkedin.com/in/mgiovagnini

2008\04\15@130821 by Ivan Petrushev
picon face
Hi there,
I'm still stuck on that topic, altough I don't have much time to deal with it.
I've run another test on 1200bps and cheching for OERR as Mauricio
Giovagnini suggested (thanks!). This is the info I gathered from
various debugs:
- there are some numbers in the EEPROM, but these aren't sequential.
As you can see from the transmitter source I have a variable x that is
incrementing and sent over the USART on every loop. So it is
reasonable to see in the EEPROM incrementing numbers (and resetting
after 255). Instead of that I see random numbers in the memory. Well,
not so random. There are 7-8 numbers that are repeating all the time.
This is for example: 66 66 66 90 1E 90 68 66 1E FE DE 68 DE 1E ....
- interrupt routine is entered properly
- RCIF is toggled properly
- OEER errors occure at random intervals and they are more frequent if
the PIC is being powered for more time. I suppose this is due to the
IntRC unstability.

I'm thinking about running one final test at 200bps in the near days.

Thanks for all that have been with me so far :)

Regards,
Ivan.
On Tue, Apr 15, 2008 at 4:08 PM, Mauricio Giovagnini
<.....maugiovagniniKILLspamspam@spam@yahoo.com.ar> wrote:
{Quote hidden}

> -

2008\04\15@142250 by Mauricio Giovagnini

flavicon
face
Ivan Petrushev escribió:
{Quote hidden}

Ivan, check that you enabled the GIE and RCIE, and you are
using a poll-mode check.  Set GIE and RCIE to 0.  You don't
need to enable them at any means for the simple project you
are developing.

The OERR bit can be set due to too many bytes being received
while saving in eeprom or due to some noise on the receiver
pin.  A Vdd to GND pulse will be interpreted as a UART Start
bit and you'll then receive the byte willing or not.

1200 bps = 8.3 mseg typical, you shouldn't have too many
problems with this assuming that your EEPROM writing routine
is working fine.

Check that the baud rates are equal on both sides, do you
have scope to check if you really are sending accurate data?

Can you delay the startup of your receiver software? im
guessing some noise on the RXpin .

ALso tset the software sending always the same byte on the
transmitter.  This is a good way to test that your baud rate
is equal on both sides.

I hope this helps
Be well



--
------------------------------
Mauricio Giovagnini (Maunix)
http://www.maunix.com.ar
Cordoba, Arg.
LinkedIn Profile: http://www.linkedin.com/in/mgiovagnini

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...