Calgarypuck Forums - The Unofficial Calgary Flames Fan Community

Go Back   Calgarypuck Forums - The Unofficial Calgary Flames Fan Community > Main Forums > The Off Topic Forum
Register Forum Rules FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 03-12-2010, 06:39 PM   #1
Double_Dion
Crash and Bang Winger
 
Join Date: Mar 2007
Exp:
Default 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.
Double_Dion is offline   Reply With Quote
Old 03-12-2010, 07:39 PM   #2
Peanut
First Line Centre
 
Join Date: Oct 2006
Location: Fantasy Island
Exp:
Default

... tech talk forum?!
Peanut is offline   Reply With Quote
Old 03-12-2010, 07:45 PM   #3
FanIn80
GOAT!
 
FanIn80's Avatar
 
Join Date: Jun 2006
Exp:
Default

I'm still staring at his avatar...
FanIn80 is offline   Reply With Quote
Old 03-12-2010, 07:50 PM   #4
Bigtime
Franchise Player
 
Bigtime's Avatar
 
Join Date: Apr 2008
Location: Calgary
Exp:
Default

Bigtime is online now   Reply With Quote
The Following 3 Users Say Thank You to Bigtime For This Useful Post:
Old 03-12-2010, 08:05 PM   #5
Mike F
Franchise Player
 
Mike F's Avatar
 
Join Date: Jul 2003
Location: Djibouti
Exp:
Default

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
Mike F is offline   Reply With Quote
Old 03-12-2010, 08:36 PM   #6
bcb
Scoring Winger
 
bcb's Avatar
 
Join Date: Jun 2008
Location: Calgary
Exp:
Default

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)

bcb is offline   Reply With Quote
The Following User Says Thank You to bcb For This Useful Post:
Old 03-12-2010, 09:20 PM   #7
Regulator75
Franchise Player
 
Regulator75's Avatar
 
Join Date: Oct 2001
Location: Behind Nikkor Glass
Exp:
Default

Ctrl - F4
__________________

More photos on Flickr
Regulator75 is offline   Reply With Quote
Old 03-12-2010, 10:55 PM   #8
MelBridgeman
Lifetime Suspension
 
Join Date: Mar 2007
Location: Calgary
Exp:
Default

popen()
fputs()
?

not much of a device control dude
MelBridgeman is offline   Reply With Quote
Old 03-13-2010, 12:18 AM   #9
ZedMan
Scoring Winger
 
Join Date: Apr 2008
Exp:
Default

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
ZedMan is offline   Reply With Quote
Old 03-13-2010, 12:28 AM   #10
Huntingwhale
Franchise Player
 
Huntingwhale's Avatar
 
Join Date: Sep 2008
Exp:
Default

Huntingwhale is offline   Reply With Quote
Old 03-13-2010, 11:12 AM   #11
Double_Dion
Crash and Bang Winger
 
Join Date: Mar 2007
Exp:
Default

No electrical engineers or robot/electronic hobbyists in here?

Last edited by Double_Dion; 09-07-2010 at 10:10 PM.
Double_Dion is offline   Reply With Quote
Old 03-13-2010, 11:15 AM   #12
Muta
Franchise Player
 
Muta's Avatar
 
Join Date: Mar 2002
Location: Auckland, NZ
Exp:
Default

That **** scares me.
Muta is online now   Reply With Quote
Old 03-13-2010, 11:20 AM   #13
FanIn80
GOAT!
 
FanIn80's Avatar
 
Join Date: Jun 2006
Exp:
Default

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.
FanIn80 is offline   Reply With Quote
Old 03-13-2010, 11:32 AM   #14
Double_Dion
Crash and Bang Winger
 
Join Date: Mar 2007
Exp:
Default

Quote:
Originally Posted by FanIn80 View Post
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?
Double_Dion is offline   Reply With Quote
The Following User Says Thank You to Double_Dion For This Useful Post:
Old 03-13-2010, 11:56 AM   #15
Phanuthier
Franchise Player
 
Phanuthier's Avatar
 
Join Date: Feb 2002
Location: Silicon Valley
Exp:
Default

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
Phanuthier is offline   Reply With Quote
Old 03-13-2010, 11:59 AM   #16
Rathji
Franchise Player
 
Rathji's Avatar
 
Join Date: Nov 2006
Location: Supporting Urban Sprawl
Exp:
Default

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."
Rathji is offline   Reply With Quote
Old 03-13-2010, 12:10 PM   #17
_Q_
#1 Goaltender
 
_Q_'s Avatar
 
Join Date: Jan 2009
Location: Calgary
Exp:
Default

Quote:
Originally Posted by Double_Dion View Post
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.
_Q_ is offline   Reply With Quote
Old 03-13-2010, 12:27 PM   #18
Double_Dion
Crash and Bang Winger
 
Join Date: Mar 2007
Exp:
Default

Quote:
Originally Posted by _Q_ View Post
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.
Double_Dion is offline   Reply With Quote
Old 03-13-2010, 12:58 PM   #19
FlamingStuffedTiger
Backup Goalie
 
FlamingStuffedTiger's Avatar
 
Join Date: Mar 2009
Location: Vancouver
Exp:
Default

I am no electrical engineer, but from my limited experiences with C, this is probably how its done:

Quote:
Originally Posted by ZedMan View Post
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.
FlamingStuffedTiger is offline   Reply With Quote
Old 03-13-2010, 12:59 PM   #20
Rathji
Franchise Player
 
Rathji's Avatar
 
Join Date: Nov 2006
Location: Supporting Urban Sprawl
Exp:
Default

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."
Rathji is offline   Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 02:16 PM.

Calgary Flames
2024-25




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Calgarypuck 2021 | See Our Privacy Policy