PIC stuck in allways HIGH Out.

Thread Starter

FroceMaster

Joined Jan 28, 2012
699
testet more, and some like 20 = err, 22= OK 2E = ok 30+31 = err 32+33=ok. and many more

Diggin more, when Bit 1 =0, it detects errors. ex 01 = error 00= error, 2+3 = OK, 4+5 Error, 6+7 = ok. ect.
 
Last edited:

Thread Starter

FroceMaster

Joined Jan 28, 2012
699
Baud rate is 10417 on both mcu, and in Uart tool. Now i use only mcu"slave" and Tool.
When connected to "master" and Tools i have same setting.
Have read something about inverted, when using tools, but not at pc more today
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
699
10417 is 0.00% so it will have to be a lot off ?

Can understand if it is random , but it is only when bit 1 is high.
 
Last edited:

AlbertHall

Joined Jun 4, 2014
12,345
You could try reversing the state of SCKP in BAUDCON1 from wahtever it is now. This inverts the data.
[EDIT] But I think that only affects the transmitter, not the receiver.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
699
Have been changing SCKP added BREAK Char, all posible constalations of these.
Still same problem,
Transmitter is Idle HIGH, and by look at scope it sends like this,
20200807_173939.jpg

Time div = 100 us.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
699
Transmitter 16F15356
Code:
BAUD1CON = 0x00;
RC1STA = 0x90;
TX1STA = 0x2C;   
SP1BRGL = 0xBF;    // SP1BRGL 191; BAUD 10417
SP1BRGH = 0x00;
And the receiver 16F18877
Code:
BAUD1CON = 0x08; // 16 bit baud generator.
RC1STA = 0x80; // Seriel port en.
SP1BRGL = 0xBF; //191 aka 10417 baud
SP1BRGH = 0x00;
 

AlbertHall

Joined Jun 4, 2014
12,345
191 is correct for 10417 baud if BRGH = 0 and BRG16 = 1, with a 32MHz clock.
Have you checked the oscillator frequency?
Check BRGH in TXSTA too.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
699
Acording to datasheet both mcu should run 32 mhz.

Edit. Forgot to copy the line ,
TX1STA = 0x04; // high speed

Edit2 : BRGH=1 and BRG16=0 = 32 mhz = 10417 Baud.
 
Last edited:

Thread Starter

FroceMaster

Joined Jan 28, 2012
699
Corrected BRGH=1 and BRG16 =0 , and now it recieves without errors.
What i send is what i recieve.
Now i need to figure out how to deal with data, but we are rolling. :)
Thanx for pointing out the mistake.
Any hint on why the LED flashes every seconds, i know it's du to interrupt of UART, but do it takes so long to run that small code ?
Code:
void __interrupt() myISR(void)
{// things to do
    // only interrupt is from RX EUSART
    if (RCIF==1)
   {
 
   CREN=0;
     NumbersOfRXRuns++; // add 1 to counter
   if (NumbersOfRXRuns==1) UART_Buffer1=RCREG;
   if (NumbersOfRXRuns==2) UART_Buffer2=RCREG;
   if (NumbersOfRXRuns==3) UART_Buffer3=RCREG;
   if (NumbersOfRXRuns==4) UART_Buffer4=RCREG;
   if (NumbersOfRXRuns>=5)
   {
       UART_Buffer5=RCREG;
   NumbersOfRXRuns=0;
 DataRecieve=1;
    }
  
   CREN=1;
  
  }
}
Video is here

https://www.dropbox.com/s/1y24an2vc5oje6a/20200808_145053.mp4?dl=0

.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
699
Fixed it ,,in sending code, i have a delay, on test, removed now, works now.
Can i just pick a random BAUD, ex if using 105250 Baud SPBRGB=18
Not in list, but ?
 
Top