When I programmed my 4013 in C30 I never even knew there was a startup.s. I'm pretty sure you don't need to worry about it. I think the compiler handles all that stuff for you automatically.Hey all i got a couple of these dsPIC30F4013 micros and would love some help here lol
I know so far that i need some type of startup.s file. But have no clue where to get them or how to make one. At least a link on how they work would rock!
I have that C30 from Microchip and will look closely at the help file but if anyone has a C30 "Flash/Blink LED" type of demo.
I have seen a demo for other chips from the dsPICDEM 2 examples but none fit in.
So any help would be awesome!
The configs are like 18F bits. There's tons of em!ok cool thanks. I have something that seems to be compiling now i need to set these config bits.
#include "p30f4013.h"
int delay(void);
_FOSC(FRC_PLL16) //osc
_FWDT(WDT_OFF)
_FBORPOR(MCLR_EN & PWRT_OFF)//MCLR enable & power-up timers off
_FGS(CODE_PROT_OFF) //Code Protection off
int main(void)
{
TRISB = 0; //PORTB all outputs
while(1)
{
LATBbits.LATB0=1;
delay();
LATBbits.LATB0=0;
delay();
LATBbits.LATB5=1;
delay();
LATBbits.LATB5=0;
delay();
LATBbits.LATB1=1;
delay();
LATBbits.LATB1=0;
delay();
LATBbits.LATB4=1;
delay();
LATBbits.LATB4=0;
delay();
LATBbits.LATB2=1;
delay();
LATBbits.LATB2=0;
delay();
LATBbits.LATB3=1;
delay();
LATBbits.LATB3=0;
delay();
}
return 0;
}
int delay(void)
{
int var1,var2;
for(var1=0;var1!=10;var1++)
for(var2=0;var2!=10000;var2++);
return 0;
}
#include "p30f4013.h"
_FOSC(FRC) //osc
_FWDT(WDT_OFF)
_FBORPOR(MCLR_EN & PWRT_OFF) //MCLR enable & power-up timers off
_FGS(CODE_PROT_OFF) //Code Protection off
void lcd_line1(void); //function prototypes
void lcd_line2(void);
void lcd_cmd(unsigned char);
void lcd_char(char);
void e_togg(void);
void lcd_init(void);
void lcd_string();
void lcd_busy(void);
char sentence[16] = "dsPIC 30F4013";
char *senpoint = sentence;
#define E LATDbits.LATD9
#define RS LATAbits.LATA11
#define RW LATCbits.LATC14
#define busyflag PORTBbits.RB12
#define RW_TrisBit TRISCbits.TRISC14
#define D7_TrisBit TRISBbits.TRISB12
int main(void)
{
ADPCFG = 0xffff; //all digital
TRISA = 0; //PORTs all outputs
TRISB = 0;
TRISC = 0;
TRISD = 0;
RW = 0; //set R/W low
E = 0; //set E low
// lcd_busy(); //wait for LCD to settle
// lcd_init();
lcd_string(); //send string to LCD
while(1); //spin forever
return 0;
}
void lcd_string(void)
{
while(*senpoint != '\0')
{
lcd_char(*senpoint);
senpoint++;
}
}
void lcd_busy(void)
{
RW_TrisBit = 1; //make R/W input (read)
D7_TrisBit = 1; //make D7 input
RS = 0; //set RS low
RW = 1; //set R/W high
E = 1; //set E high
while(busyflag); //wait for busy flag to go low
E = 0; //set E low
RW = 0; //set R/W low
TRISB = 0; //make D7 output
RW_TrisBit = 0; //make R/W output (write)
}
void lcd_line1(void)
{
lcd_cmd(0x80);
}
void lcd_line2(void)
{
lcd_cmd(0xc0);
}
void lcd_cmd(unsigned char letter)
{
LATB = letter; //put char in PORTB
lcd_busy();
PORTB = PORTB << 5; //shift over to output high 4 bits on RB9,10,11,12
RS = 0; //RS low
e_togg(); //latch the data
PORTB = PORTB << 4; //shift over to output low 4 bits
RS = 0; //RS low
e_togg(); //latch it
}
void lcd_char(char letter)
{
LATB = letter; //put char in PORTB
lcd_busy();
PORTB = PORTB << 5; //shift over to output high 4 bits on RB9,10,11,12
RS = 1; //RS high
e_togg(); //latch the data
PORTB = PORTB << 4; //shift over to output low 4 bits
RS = 1; //RS high
e_togg(); //latch it
}
void lcd_init(void)
{
LATB = 0x0600; //send 3
e_togg();
lcd_busy();
LATB = 0x0600;
e_togg();
lcd_busy();
LATB = 0x0600;
e_togg();
lcd_busy();
LATB = 0x0400; //send 2 - set 4-bit mode
e_togg();
lcd_busy();
lcd_cmd(0x28); //set 4-bit mode and 2 lines
lcd_busy();
lcd_cmd(0x10); //cursor move & shift left
lcd_busy();
lcd_cmd(0x06); //entry mode = increment
lcd_busy();
lcd_cmd(0x0d); //display on - cursor blink on
lcd_busy();
lcd_cmd(0x01); //clear display
lcd_busy();
}
void e_togg(void)
{
E=1;
E=0;
}
_FOSC(CSW_FSCM_OFF & HS);
_FWDT(WDT_OFF)
_FBORPOR(MCLR_EN & PWRT_OFF)
_FGS(CODE_PROT_OFF)
You're using a 20MHz crystal? I think you'd useOK the only issue im having now (or so it seems) is the FOSC setting im using 20Mhz since its all i have. How would i set it?
_FOSC(HS)
#include "p30F4013.h"
_FOSC(FRC_PLL4);
_FWDT(WDT_OFF)
_FBORPOR(MCLR_EN & PWRT_OFF)
_FGS(CODE_PROT_OFF)
int main(void)
{
int x;
int y;
y = 5000000; //[b]I tried anywhere from 500-500000[/b]
TRISB = 0x00;
LATB = 0x00;
while(1)
{
LATBbits.LATB0 = 1;
for(x=0;x<y;x++)
TRISA = 0;
LATBbits.LATB0 = 0;
}
}
#include "p30F4013.h"
_FOSC(FRC_PLL4);
_FWDT(WDT_OFF)
_FBORPOR(MCLR_EN & PWRT_OFF)
_FGS(CODE_PROT_OFF)
int main(void)
{
int x;
int y;
int z;
y = 999999; //[b]I tried anywhere from 500-500000[/b]
ADPCFG = 0xffff; //all digital
TRISB = 0;
LATB = 0;
while(1)
{
LATBbits.LATB0 = 1;
for(z=0;z<50;z++)
for(x=0;x<y;x++)
TRISA = 0;
LATBbits.LATB0 = 0;
}
}
#include "p30F4013.h"
void delay(void);
_FOSC(FRC_PLL4)
_FWDT(WDT_OFF)
_FBORPOR(MCLR_EN & PWRT_OFF)
_FGS(CODE_PROT_OFF)
int main(void)
{
TRISB = 0;
while(1)
{
LATBbits.LATB0 = 1;
delay();
LATBbits.LATB0 = 0;
delay();
}
}
void delay(void)
{
int x,y;
for(x=0;x<10;x++)
for(y=0;y<10000;y++);
return 0;
}
Yes. Three VDD and three VSS. Don't bother with the AVDD or AVSS for now.ok for physical connections i have to connect all VSS and VDD pins right? lol and Im using 5v. I got a 12k resistor to MCLR
Just bootload yer code for now. Works just fine. Only a couple extra steps each time around.I'm playing with these higher end pics for fun till i get my LPC Olimex board. Should be soon. I'm going to wait till the tiny gets in stock which is very soon i think.
All the LPC2000 line have a bootloader built-in. You connect UART0 to your computer with a serial cable. To enable the bootloader, switch a dip-switch or move a jumper, hit reset and program with Flash Magic (or other program). Then put the switch/jumper back, hit reset and your program runs. Easy.what do you mean bootload my code?
The 30F4013 is rated to 120MHz.These pics look like they can reach a nice speed....
What's wrong with hacking stuff? I would argue that hackable electronics are a very good thing. 99% of people don't have the chops or the inclination to do it, but that 1% gets great entertainment out of tinkering with things. The more hackable the better.but then if its something that others use alot it might get hacked easy.like i hear alot of people hacking a lot of things from modems to PSPs to zunes to do what they want and thats mainly because of the bootloader i would argue. Since they can get your update they can alter it and upload it. Now if it was a reprogramming then they couldnt but then again to have a huge amount of people come into a store to update a psp or zune would suck!!
"There is also a 32-KB ROM for bootstrap code and other frequently-used
code and data.
A ROM patch module provides the ability to patch the internal ROM. It can
also initiate and external boot by overriding the boot reset sequence
by a jump to a configurable address."
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?