PB with SPI with 18F26K40

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
cvoisin2003
Posts: 12
Joined: 04 Dec 2010 13:27

PB with SPI with 18F26K40

#1 Post by cvoisin2003 » 29 Dec 2019 14:31

Hi,

Now i use a PIC18F26K40 to pilot with the SPI bus a 8x7segs with Maxim 7219 driver.

With Software_SPI library all work fine.

With SPI_Remappable library nothing append. With a scope on SDO or CLK no signal appeared ?
Is this library working with 18F26K40 ?

Please, do you have a mostly recently sample of SPI program for mikroBasic Pro ?

Thank in advance and Happy Holidays

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PB with SPI with 18F26K40

#2 Post by jovana.medakovic » 30 Dec 2019 11:10

Hello,

The PPS Lock bit in config has to be set to Allow multiple reconfigurations.
Also, you need to map Serial Clock as input and output.

Can you zip and send me your project for review?

Kind regards,
Jovana

cvoisin2003
Posts: 12
Joined: 04 Dec 2010 13:27

Re: PB with SPI with 18F26K40

#3 Post by cvoisin2003 » 30 Dec 2019 12:40

Hi,

I modify PPS lock bit to multiple reconfiguration but no result.
You can find the project in file attachment.

Regards,

Christophe
Attachments
Max7219.rar
8x7segs project
(43.34 KiB) Downloaded 83 times

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PB with SPI with 18F26K40

#4 Post by jovana.medakovic » 09 Jan 2020 12:52

Hi Christophe,

I apologize for the delayed answer.

In the attachment, you can find the corrected project. Let me know if it works.

Kind regards,
Jovana
Attachments
Max7219.zip
(63.46 KiB) Downloaded 87 times

cvoisin2003
Posts: 12
Joined: 04 Dec 2010 13:27

Re: PB with SPI with 18F26K40

#5 Post by cvoisin2003 » 09 Jan 2020 19:18

Hi Jovana,

Thank you for your time.

I am disapointed because the code not working and i would like to solve my problem.

All segments are light on but nothing append after reboot. After i am trying the softcode and all working fine ?

Regards

Christophe

cvoisin2003
Posts: 12
Joined: 04 Dec 2010 13:27

Re: PB with SPI with 18F26K40

#6 Post by cvoisin2003 » 13 Jan 2020 09:12

Hi,

Now all is working fine.

Solution :

1) PPS define need to be change because SPI output is RC4.
2) Clock to manage SPI need to be : FOSC/64.

Last question before close this subject : Can you send me an update of PPS library with correct input and output constant value to those contained in your response (constant like _SDO1_SDA1, _SCK1_SCL1; ...)

Many thanks.

Christophe

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PB with SPI with 18F26K40

#7 Post by jovana.medakovic » 16 Jan 2020 12:48

Hello,

Can you tell me which version of the compiler you are using?
On the following link, you can find the latest version where you should have these constants:
https://download.mikroe.com/setups/comp ... p-v760.zip

Kind regards,
Jovana

cvoisin2003
Posts: 12
Joined: 04 Dec 2010 13:27

Re: PB with SPI with 18F26K40

#8 Post by cvoisin2003 » 17 Jan 2020 19:17

Hi,

I am using PICBASIC Version 7.6

Regards,

Christophe

cvoisin2003
Posts: 12
Joined: 04 Dec 2010 13:27

Re: PB with SPI with 18F26K40

#9 Post by cvoisin2003 » 26 Mar 2020 22:07

Hi Jovana,

Now, i use PIC18F27K42 instead of PIC18F26K40 and i would like to run the same program but i have a problem with PPS output mapping. I have no problem for INPUT mapping.

I hope mapping my SPI module like this :

Unlock_IOLOCK()
PPS_Mapping(_RC3, _OUTPUT, ?SCK?)
PPS_Mapping(_RC2, _INPUT, SPI1SDIPPS)
PPS_Mapping(_RC4, _OUTPUT, ?SDO?)
Lock_IOLOCK()

Can you help me ?

Regards

Christophe

cvoisin2003
Posts: 12
Joined: 04 Dec 2010 13:27

Re: PB with SPI with 18F26K40

#10 Post by cvoisin2003 » 27 Mar 2020 09:33

Hi Jovana,

This morning with clear ideas, I found the information I was looking for:

Unlock_IOLOCK ()
RC3PPS =% 011110 'SCK
RC4PPS =% 011111 'SDO
PPS_Mapping (_RC2, _INPUT, SPI1SDIPPS)
Lock_IOLOCK ()

Sorry for the inconvenience

Regards

Christophe

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PB with SPI with 18F26K40

#11 Post by jovana.medakovic » 27 Mar 2020 11:01

Hello,

You also can try on this way:

Unlock_IOLOCK()
PPS_Mapping(_RC3, _OUTPUT, _SCK1)
PPS_Mapping(_RC2, _INPUT, _SDI1)
PPS_Mapping(_RC4, _OUTPUT, _SDO1)
Lock_IOLOCK()

Kind regards,
Jovana

cvoisin2003
Posts: 12
Joined: 04 Dec 2010 13:27

Re: PB with SPI with 18F26K40

#12 Post by cvoisin2003 » 27 Mar 2020 11:31

Hi Jovana,

Yes, it is more simple like this !

Thanks, have a good day

Christophe

Post Reply

Return to “mikroBasic PRO for PIC General”