Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help with simple LED program using dsPIC.

Status
Not open for further replies.

dgchaos

Newbie level 4
Newbie level 4
Joined
Apr 13, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,327
I'm new to dsPIC programming. I decided to try a simple LED blinking project using Proteus ISIS and the MikroC compiler.

void main() {

LATB=0xFFFF;
while(1) {

LATB=~LATB;
Delay_ms(1000);
}
}

So I hooked up a dsPIC33fj32mc202 to a 16 segment display and it started blinking. Yay.

I made a small change in the program. instead of LATB=0xFFFF, I made it LATB=0x8000. So in theory, only one segment should light up at first and then the remaining should be on while the first one is off, right? Instead, the entire godforsaken 16 segment display kept blinking like before. What am I doing wrong here?

I loaded the .hex again and all that. What could be wrong?

My apologies, the actual code was the following. I had not forgotten TRIS:
EDIT_________________________
void main() {
ADPCFG=0XFFFF;
TRISB=0;
LATB=0xFFFF;
while(1) {

LATB=~LATB;
Delay_ms(1000);
}
}
_____________________________________
delete.png
 
Last edited:


Code C - [expand]
1
2
3
4
5
6
7
8
9
void main() {
 
[B]TRISB = 0x00;[/B]
while(1) {
 
LATB=~LATB;
Delay_ms(1000);
}
}



Write TRISB = 0x00;

- - - Updated - - -

By Default all ports are input ports.
Means they have logic high by default.
You did not set ports to out put port

TRISB = 0;
will do so
and you will get everything properly
 
Thanks. I had put the wrong code here earlier. Sorry.

I had already included TRISB=0; in my program.

I think the problem was with the ISIS model. I was able to get it working with a different dsPIC model.
 

I made a small change in the program. instead of LATB=0xFFFF, I made it LATB=0x8000. So in theory, only one segment should light up at first and then the remaining should be on while the first one is off, right? Instead, the entire godforsaken 16 segment display kept blinking like before. What am I doing wrong here?

post this program too..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top