Problem with Mikromedia PIC32 and MCP3208

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
Darklakebridge78
Posts: 136
Joined: 12 May 2007 14:04
Location: Italy
Contact:

Problem with Mikromedia PIC32 and MCP3208

#1 Post by Darklakebridge78 » 20 Oct 2020 15:22

Hello everyone!
I would need to control an MCP3208 with a Mikromedia for PIC32 board. On the forum I found only 8 bit PIC examples, but nothing that works with the Mikrobasic PRO for PIC32. Can anybody help me? This code doesn't work ... :cry:

Code: Select all

sub function ReadMCP2308(dim channel as byte) as word
dim tmp as word
dim txbyte as byte

   Chip_Select = 0
        
   if channel <= 3 then
      txbyte = 6 
   end if
   
   if ((channel > 3) and (channel < 8)) then 
       txbyte = 7 
   end if
   
   SPI2_Write(txbyte)
   channel = channel << 6 
   tmp = SPI2_Read(channel) and 0x0f 
   tmp = tmp << 8 
   tmp = tmp or SPI2_Read(0) 
   
   Chip_Select = 1 
   result = tmp
end sub
Mikroe team any idea?

Thank you so much!
MikroC PRO for PIC, MikroC PRO for dsPIC, MikroC PRO for PIC32, MikroC PRO for ARM, Visual TFT, Visual GLCD,
http://www.teolab.it

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Problem with Mikromedia PIC32 and MCP3208

#2 Post by filip » 23 Oct 2020 11:29

Hi,

I have no experience with MCP3208, but the 3204 should be fairly similar :
https://github.com/MikroElektronika/ADC_click

Regards,
Filip.

Post Reply

Return to “mikroBasic PRO for PIC32 General”