• AVR Freaks

Helpful ReplyPIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS ISSUE

Author
anniyanx
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2006/11/06 21:25:37
  • Location: 0
  • Status: offline
2019/11/21 22:38:41 (permalink)
0

PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS ISSUE

Hi im using a PIC 16 EXPLORER board with a DSPIC33EP512MU810 PIM module. on the PIC16 explorer board [interface A]
i connected a digilent PmodACL module which is a ADXL345 digital accelerometer.
 
PmodACL is connected to SCK/P10, MISO/P11, MOSI/P12 and CS/P14, this are the standard connections for SPI2 peripheral which is also configured accordingly in the firmware. The SPI2 peripheral is configured at clock speed 1.875Mhz. The clock edge and Clock polarity is both set to 1 according to the ADXL345 datasheet. basically im using a slightly modified microchip adxl345 driver code provided by analog device.
 
my problem is after inserting the PmodACL module on the Pmod interface A at PIC explorer16 board, and run the code,i cant
get the ADXL345 device ID. after using oscilloscope and checking on the CLOCK pin and MISO pin, i find out that PmodACL  module is actually responding with a device ID, but that device ID is not read properly/correctly by the microcontroller into its buffers or it never being detected by the dspic at all, as such something is going wrong here.
for I/O port settings as im using and enabling SPI2,as per that it is automatically configured. 
 
the SPI reading into buffers code is as below:-
 
unsigned char SPI_Read(unsigned char slaveDeviceId,
                       unsigned char* data,
                       unsigned char bytesNumber)
{
    unsigned char byte = 0;
    unsigned char writeBuffer[4] = {0, 0, 0, 0};
    for(byte = 0; byte < bytesNumber; byte++)
    {
        writeBuffer[byte] = data[byte];
    }
    if(slaveDeviceId == 1)
    {
        PMOD1_CS_LOW;
    }
    for(byte = 0; byte < bytesNumber; byte++)
    {
        SPI2BUF = writeBuffer[byte]; //write to
        while(SPI2STATbits.SPIRBF == 0);// 
        data[byte] = SPI2BUF; //read from
    }
    if(slaveDeviceId == 1)
    {
        PMOD1_CS_HIGH;
    }

    return bytesNumber;
}


the software buffer data[0] and data[1] always receive 0x00. but on the Dspic pin MISO pin the device ID is being received, meaning the PmodACL module responded correctly to the SPI read device ID command.
 
only issue i find is the clock signal is very small about 400mv only and MISO signal approx 3.0V++ on the hardware board PIC 16 explorer. im attaching the scope image for reference. As im just using a Basic SPI2 peripheral of the DSPIC33EP,i believe the provided driver code from analog device should be compatible... im still debugging this issue and my posting reason is get some ides,tips on how fix this. below is the scope screenshot the device ID is 0xE5:- 
 

post edited by anniyanx - 2019/11/21 22:40:13

Attached Image(s)

#1
jtemples
عُضْوٌ جَدِيد
  • Total Posts : 11420
  • Reward points : 0
  • Joined: 2004/02/13 12:31:19
  • Location: Southern California
  • Status: offline
Re: PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS IS 2019/11/21 23:34:00 (permalink)
0
What has led you to believe that a 400 mV signal would be considered a logic high?
#2
anniyanx
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2006/11/06 21:25:37
  • Location: 0
  • Status: offline
Re: PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS IS 2019/11/21 23:43:57 (permalink)
0
jtemples
What has led you to believe that a 400 mV signal would be considered a logic high?


yup i know  its not, that why im thinking the might some hardware issue btwn the pic16explorer board and pmodACL connection which may cause the clock voltage issue...guess i need look at both the schematics and verify.....on the other hand how the adxl345 is responding with 0xE5,which is teh device id.. something i doing wrong here..sad: sad???
#3
MBedder
Circuit breaker
  • Total Posts : 6804
  • Reward points : 0
  • Joined: 2008/05/30 11:24:01
  • Location: Zelenograd, Russia
  • Status: offline
Re: PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS IS 2019/11/22 00:55:20 (permalink) ☄ Helpfulby anniyanx 2019/11/25 01:35:09
4.5 (2)
jtemplesWhat has led you to believe that a 400 mV signal would be considered a logic high?
He just didn't tell his scope that the 10:1 probe is being used.


#4
anniyanx
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2006/11/06 21:25:37
  • Location: 0
  • Status: offline
Re: PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS IS 2019/11/22 02:11:47 (permalink)
0
MBedder
jtemplesWhat has led you to believe that a 400 mV signal would be considered a logic high?
He just didn't tell his scope that the 10:1 probe is being used.





oh yup..i just checked...it 10:1 probe.... LoL: LoL, im just using 2 different probe....
 
 
 
 
 
 
#5
ric
Super Member
  • Total Posts : 24540
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS IS 2019/11/22 02:17:51 (permalink) ☄ Helpfulby anniyanx 2019/11/25 01:35:15
0
SDI2 is an analog capable pin. Have you switched it to digital mode?
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#6
anniyanx
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2006/11/06 21:25:37
  • Location: 0
  • Status: offline
Re: PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS IS 2019/11/25 01:39:12 (permalink)
0
ric
SDI2 is an analog capable pin. Have you switched it to digital mode?
 


Yup  after setting the ANSEL bits accordingly and also set the CKP and CKE accordingly, it works. anyway i thought using SPI 2 automatically takecare the I/O ports. mr green: mr green  and also My CKE and CKP was set wrongly for the SPI communications,  CKP=1 and CKE=0 works.
post edited by anniyanx - 2019/11/25 01:44:01
#7
ric
Super Member
  • Total Posts : 24540
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS IS 2019/11/25 01:46:31 (permalink)
0
anniyan_x
...
anyway i thought using SPI 2 automatically takecare the I/O ports

Some peripherals automatically control the direction, but it is always YOUR responsibility to set the correct analog/digital mode.
 
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#8
du00000001
Just Some Member
  • Total Posts : 3225
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: PIC 16 EXPLORER BOARD (DSPIC33EP512MU810) and PmodACL (adxl345) SPI COMMUNICATIONS IS 2019/11/25 02:34:58 (permalink)
0
anniyanx
... I thought ...

 
No way! MCC creates code for whatever you "clicked together". OK - even a bit more. But don't expect too much automatism or even "intelligence".

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#9
Jump to:
© 2019 APG vNext Commercial Version 4.5