03-12-2010, 06:39 PM
|
#1
|
Crash and Bang Winger
|
dsPic30F3014 SPI interfacing
I am using MPLAB compiler and I am using a dsPic mcu. I am trying to interface with the spi to send data to a peripheral (audio attenuator) using C coding. I think I have the initialization correct, but I am stumped.
//************************************************** **********//
#include <stdio.h>
_FOSC(CSW_FSCM_OFF & XT_PLL8); // (clock switching and fail safe monitor are disabled &
// crystal connected to OSC1 is the clock source (8x PLL applied, primary oscillator)
_FWDT(WDT_OFF); // Watchdog timer disabled
_FBORPOR(PBOR_OFF & BORV_27 & PWRT_16 & MCLR_EN); // Brown-out reset disabled &_____&____& MCLR reset enabled
#define FCY 8000000 // Instruction cycle rate (Osc(4Mhz) x PLL(8) / 4) = 8 MIPS
#define T1Period 800 // T1Period = FCY*100 us = 800
void setup_spi();
int main()
{
setup_spi();
return 0;
}
//***********************
void setup_spi()
{
SPI1CON = 0x063E; // 0000 | 0110 | 0011 | 1110
SPI1STAT = 0x8000; // enable SPI port
printf("To C, or not to C: that is the question.\n");
return;
}[/CODE]
Last edited by Double_Dion; 09-07-2010 at 10:13 PM.
|
|
|
03-12-2010, 07:39 PM
|
#2
|
First Line Centre
Join Date: Oct 2006
Location: Fantasy Island
|
... tech talk forum?!
|
|
|
03-12-2010, 07:45 PM
|
#3
|
GOAT!
|
I'm still staring at his avatar...
|
|
|
03-12-2010, 07:50 PM
|
#4
|
Franchise Player
Join Date: Apr 2008
Location: Calgary
|
|
|
|
The Following 3 Users Say Thank You to Bigtime For This Useful Post:
|
|
03-12-2010, 08:05 PM
|
#5
|
Franchise Player
Join Date: Jul 2003
Location: Djibouti
|
I have no idea what you're talking about, but I'd be willing to bet any 6 year old could do it in between naps
|
|
|
03-12-2010, 08:36 PM
|
#6
|
Scoring Winger
Join Date: Jun 2008
Location: Calgary
|
uhhh.
Control Alt Delete???
__________________
“The fact is that censorship always defeats it's own purpose, for it creates, in the end, the kind of society that is incapable of exercising real discretion.”
Henry Steel Commager (1902-1998)
|
|
|
The Following User Says Thank You to bcb For This Useful Post:
|
|
03-12-2010, 09:20 PM
|
#7
|
Franchise Player
Join Date: Oct 2001
Location: Behind Nikkor Glass
|
Ctrl - F4
|
|
|
03-12-2010, 10:55 PM
|
#8
|
Lifetime Suspension
Join Date: Mar 2007
Location: Calgary
|
popen()
fputs()
?
not much of a device control dude
|
|
|
03-13-2010, 12:18 AM
|
#9
|
Scoring Winger
|
From my limited experience you most likely have to put the data you want to send into a specific register.
Have you looked at the documentation? Microchip inc. probably has it on their website.
Also try being less specific when you search, i.e. just dspic30f instead of the whole name.
-edit-
this should help... http://digikey.com/PTM/IndividualPTM...ng=en&ptm=5610
|
|
|
03-13-2010, 11:12 AM
|
#11
|
Crash and Bang Winger
|
No electrical engineers or robot/electronic hobbyists in here?
Last edited by Double_Dion; 09-07-2010 at 10:10 PM.
|
|
|
03-13-2010, 11:15 AM
|
#12
|
Franchise Player
Join Date: Mar 2002
Location: Auckland, NZ
|
That **** scares me.
|
|
|
03-13-2010, 11:20 AM
|
#13
|
GOAT!
|
Oh wait a minute... I've seen this problem before. Just wiggle the wire a bit on the Catastrophic Converter, and you should be fine.
|
|
|
03-13-2010, 11:32 AM
|
#14
|
Crash and Bang Winger
|
Quote:
Originally Posted by FanIn80
Oh wait a minute... I've seen this problem before. Just wiggle the wire a bit on the Catastrophic Converter, and you should be fine.
|
You're still looking at my avatar, aren't you?
|
|
|
The Following User Says Thank You to Double_Dion For This Useful Post:
|
|
03-13-2010, 11:56 AM
|
#15
|
Franchise Player
Join Date: Feb 2002
Location: Silicon Valley
|
Poor sucker, Loren isn't helping you?
__________________
"With a coach and a player, sometimes there's just so much respect there that it's boils over"
-Taylor Hall
|
|
|
03-13-2010, 11:59 AM
|
#16
|
Franchise Player
Join Date: Nov 2006
Location: Supporting Urban Sprawl
|
Hey,
I went and found a thread of clearly intelligent people who are discussing this exact issue right now.
http://tinyurl.com/yz7jvbs
Its the top link! I don't know how you missed it!
__________________
"Wake up, Luigi! The only time plumbers sleep on the job is when we're working by the hour."
|
|
|
03-13-2010, 12:10 PM
|
#17
|
#1 Goaltender
Join Date: Jan 2009
Location: Calgary
|
Quote:
Originally Posted by Double_Dion
No electrical engineers or robot/electronic hobbyists in here?
I have searched all over the web for over 15 hours, Ive looked through textbooks, I have seen that tutorial, but nothing gives me an example. I know I need to send it the the SPI1BUF but I need the commands that will do that for me. Every example code I look at is either in a different language or it uses special compilers with specific libraries, so I can't decipher what is going on.
|
I'm an electrical engineer and this is the reason why I work in Power transmission and distribution. I don't have to look at C/C++ code ever again in my life. This kind of stuff down right scares the crap out of me, I could never understand why anyone would willingly put themselves through this.
|
|
|
03-13-2010, 12:27 PM
|
#18
|
Crash and Bang Winger
|
Quote:
Originally Posted by _Q_
I'm an electrical engineer and this is the reason why I work in Power transmission and distribution. I don't have to look at C/C++ code ever again in my life. This kind of stuff down right scares the crap out of me, I could never understand why anyone would willingly put themselves through this.
|
I'm hoping to get a job in power.
Last edited by Double_Dion; 09-07-2010 at 10:10 PM.
|
|
|
03-13-2010, 12:58 PM
|
#19
|
Backup Goalie
Join Date: Mar 2009
Location: Vancouver
Exp:  
|
I am no electrical engineer, but from my limited experiences with C, this is probably how its done:
Quote:
Originally Posted by ZedMan
From my limited experience you most likely have to put the data you want to send into a specific register.
Have you looked at the documentation? Microchip inc. probably has it on their website.
Also try being less specific when you search, i.e. just dspic30f instead of the whole name.
-edit-
this should help... http://digikey.com/PTM/IndividualPTM...ng=en&ptm=5610
|
You just have to figure out which registers are involved in what you want to do and how to go about filling them properly in your language/library of choice. There should be documentation for all of this somewhere... Maybe like this?
http://www.microchip.com/wwwproducts...cName=en010344
Maybe I'm just spewing nonsense because this is definately not my area of expertise but, I hope it helps heh...
Btw, is this you?
http://www.electro-tech-online.com/m...terfacing.html
I'll bet you will get a better answer there than in the off-topic section of a hockey forum
Last edited by FlamingStuffedTiger; 03-13-2010 at 01:03 PM.
|
|
|
03-13-2010, 12:59 PM
|
#20
|
Franchise Player
Join Date: Nov 2006
Location: Supporting Urban Sprawl
|
Using assembly to get to the registers seems like the easiest bet to me. Most API stuff pulls stuff directly from a specific register.
__________________
"Wake up, Luigi! The only time plumbers sleep on the job is when we're working by the hour."
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -6. The time now is 02:16 PM.
|
|