Go to Post At this point in build season, I'm thinking that whatever type we can get built and working is the best type, by far! - MrForbes [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 01-07-2010, 21:34
matrix_manshy matrix_manshy is offline
Registered User
no team
 
Join Date: Apr 2010
Location: egypt
Posts: 6
matrix_manshy is an unknown quantity at this point
spi interface with accelerometer and pic 18f448 problem

hi i am new user to microcontroller and accelerometer adxl345 i have a great problem in interfacing the spi of picadxl345 and pic 18f448 as i want to write to an addresses of registers inside the accelerometer with special data to be configured to read displacemmment "after double integeration" i have a great problem in in how to differentiate between the data and adress as in the accelerometer datasheet there are 2 bit in begining of address (1 for read ,o for write ) and other bit used for multiple bit and then 6 bit address and data 8 bit what i want to know if i can make both by write spi after each other only and after them what to start new transmission ? and other i dont know if i set bit 1 for read i enter as example char x=readspi() only after it ?

last question and i am sorry for long question is to configure uart from output of spi to be at out put i want to see an example of this case please because really i am in great troouble as my graduation project presentation in less than 2 weeks
#include <p18f448.h>
#include <usart.h>
#include <delays.h>
#include<stdlib.h>
#include<stdio.h>
#include <spi.h>
#define SPI_CS LATBbits.LATB0
char x,y[2],o;
int m;
void delay (void)
{
int i;
for (i = 0; i < 3500; i++)
;
}
void delay1 (void)
{
int i;
for (i = 0; i < 1000; i++)
;
}
void delay2 (void)
{
int i;
for( i=0;i<=366;i++);

}
void main (void)
{
OpenSPI(SPI_FOSC_16, MODE_00, SMPEND);
OpenUSART(USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,92);

TRISB=0x00;
while(1){LATBbits.LATB0=0b0;
WriteSPI(0x6D); // adress of accelerometer
WriteSPI(0x01); //data
Delay10KTCYx( 50 );
LATBbits.LATB0=0b1;
Delay10KTCYx( 20 );
LATBbits.LATB0=0b0;
WriteSPI(0xED);//to enable write bit
o=ReadSPI();
LATBbits.LATB0=0b1;

m=o; // to convert to integer
itoa(m,y);//to be read by uart
putrsUSART("id");
putrsUSART(" ");
putsUSART( y);
putrsUSART(" ");
}}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ADXL345 SPI Accelerometer set/get Refnum Jon236 NI LabVIEW 3 16-02-2010 10:20
SPI interface for cRIO in C++?? Dale Programming 4 18-01-2010 20:15
Team 2102 Problem With Control Interface kevinbrice Control System 15 16-10-2009 23:56
More Problem With Accelerometer SamRI Electrical 6 01-02-2009 22:31
Software SPI Interface Greg Programming 11 08-02-2004 21:38


All times are GMT -5. The time now is 14:59.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi