SPI and UART Together on PIC18F45K22

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
Jimbotnik
Posts: 42
Joined: 20 Jan 2010 14:27

SPI and UART Together on PIC18F45K22

#1 Post by Jimbotnik » 03 Sep 2022 00:09

Hello,

I would like to use both SPI and UART on the same chip (PIC18F45K22)

I can only get SPI to work if I set the "4 x PLL Enable Bit" to 0

I can only get UART to work if I set the "4 x PLL Enable Bit" to 1

FOSC is set to 32MHz

Am I able to get both of them working together?

Thanks for any help,

Jim

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: SPI and UART Together on PIC18F45K22

#2 Post by hexreader » 03 Sep 2022 22:40

You have not shown any code, or stated what SPI device you are using, so the following is guesswork...

Maybe you have initialised SPI using SPI1_Init() function?

This gives a high SPI clock rate, which may be too fast for your SPI slave

Try slower SPI clock by using init function something like:

Code: Select all

SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);                    // Initialize SPI module with slow clock
Start every day with a smile...... (get it over with) :)

Jimbotnik
Posts: 42
Joined: 20 Jan 2010 14:27

Re: SPI and UART Together on PIC18F45K22

#3 Post by Jimbotnik » 04 Sep 2022 23:29

Thank you hexreader! Your suggestion fixed it!

Post Reply

Return to “mikroC PRO for PIC General”