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.

PWM1L2//DAC1RN/RP13/RB13 dsPIC33fj128mc804

Status
Not open for further replies.

EmbeddedKhan

Newbie level 5
Joined
Sep 25, 2016
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
78
I am using this pin for simple led out put (LED blink) but it doesnt work the code is okay running debugging all ok but led remains off when i write configuration bit as
#pragma config LPOL = OFF
the led then remains on but blinking not occurs
 

Hi,

re read your post and try to find out how we can help with the given informations.

--> Post your code and your schematic.

Klaus
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * File:   main.c
 * Author: EmbeddedKhan
 *
 * Created on March 14, 2017, 8:19 PM
 */
 
 
// DSPIC33FJ128MC804 Configuration Bit Settings
#include <p33FJ128MC804.h>
// 'C' source line config statements
#pragma config BWRP = WRPROTECT_OFF
#pragma config GWRP = OFF               //User program memory is not write-protected
#pragma config FNOSC = PRI              // Oscillator Mode (Primary Oscillator (XT, HS, EC) w/ PLL)
#pragma config POSCMD = HS             // Primary Oscillator Source (HS Oscillator Mode)
#pragma config OSCIOFNC = ON           // OSC2 Pin Function (OSC2 pin has clock out function)
#pragma config FCKSM = CSDCMD           // Clock Switching and Monitor (Both Clock Switching and Fail-Safe Clock Monitor are disabled)   
#pragma config IESO = OFF
#pragma config ICS = PGD3               // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
#pragma config JTAGEN = OFF
#pragma config FPWRT = PWR1
#pragma config FWDTEN = OFF//ON
#pragma config WDTPOST = PS1024
#pragma config WDTPRE = PR128
#pragma config LPOL = OFF
#pragma config IOL1WAY = ON
//#pragma config HPOL = ON
#pragma config PWMPIN = OFF
 
 
 
#define TestLED         LATBbits.LATB13
 
void Delay(unsigned int Time);
 
void Delay(unsigned int Time){
    unsigned int i,j;
    for(i = 0; i < 120; i++)
        for(j = 0; j < Time; j++);
        return;
}
void GPIOConfig(void){
  
    TRISB = 0;
    Nop();
    TestLED = 0;
    return;
}
int main(void) {
   TestLED = 0;
    
    GPIOConfig();
//    LATBbits.LATB13 = 1;
//    LATAbits.LATA7 = 1;
    while(1){
        Delay(100);
      TestLED = 1;
      Delay(1000);
      TestLED = 0;
      Delay(1000);
    }
    
    return 0;
}

 
Last edited by a moderator:

Hi,

Is it really a good idea to waste 100% of processing time only to blink a LED?

Why don´t you use hardware_PWM (takes 0% of processing time)
or blink using timer ISR (takes less than 1% processing time)

Klaus

BTW: what does a scope connected to the LED show?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top