xpress_embedo
Advanced Member level 4
- Joined
- Jul 5, 2011
- Messages
- 1,154
- Helped
- 161
- Reputation
- 396
- Reaction score
- 189
- Trophy points
- 1,353
- Location
- India
- Activity points
- 10,591
I just started using PIC32 Family and found a very strange thing, maybe it is possible that i did not noticed these things earlier but noticed now.
I am using PIC32MX534F064H Micro-Controller, for Starting PIC 32 Series.
I write a simple bit toggling program.
Here it is
Just see this variable unsigned int time, in MPLAB C32 Compiler it consumes 4-bytes of memory.
When i see Memory Window it says Zero Why??
And when i changed the unsigned int time = 500; to outside the main, means global declaration, it consumes memory and also rom gets incremented.
See this
Even the lines.
unsigned int time;
then time = 500;
Showing different consumption in rom.
I am going to see dis-assembly of this code.
I am using PIC32MX534F064H Micro-Controller, for Starting PIC 32 Series.
I write a simple bit toggling program.
Here it is
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 65 66 // PIC32MX534F064H Configuration Bit Settings #include <p32xxxx.h> // DEVCFG3 // USERID = No Setting #pragma config FSRSSEL = PRIORITY_7 // SRS Select (SRS Priority 7) #pragma config FCANIO = ON // CAN I/O Pin Select (Default CAN I/O) #pragma config FUSBIDIO = ON // USB USID Selection (Controlled by the USB Module) #pragma config FVBUSONIO = OFF // USB VBUS ON Selection (Controlled by Port Function) // DEVCFG2 #pragma config FPLLIDIV = DIV_2 // PLL Input Divider (2x Divider) #pragma config FPLLMUL = MUL_20 // PLL Multiplier (20x Multiplier) #pragma config UPLLIDIV = DIV_2 // USB PLL Input Divider (2x Divider) #pragma config UPLLEN = ON // USB PLL Enable (Enabled) #pragma config FPLLODIV = DIV_1 // System PLL Output Clock Divider (PLL Divide by 1) // DEVCFG1 #pragma config FNOSC = PRIPLL // Oscillator Selection Bits (Primary Osc w/PLL (XT+,HS+,EC+PLL)) #pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disabled) #pragma config IESO = OFF // Internal/External Switch Over (Disabled) #pragma config POSCMOD = XT // Primary Oscillator Configuration (XT osc mode) #pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled) #pragma config FPBDIV = DIV_1 // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/1) #pragma config FCKSM = CSECME // Clock Switching and Monitor Selection (Clock Switch Enable, FSCM Enabled) #pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576) #pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls)) // DEVCFG0 #pragma config DEBUG = OFF // Background Debugger Enable (Debugger is disabled) #pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select (ICE EMUC2/EMUD2 pins shared with PGC2/PGD2) #pragma config PWP = OFF // Program Flash Write Protect (Disable) #pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled) #pragma config CP = OFF // Code Protect (Protection Disabled) //////////////////////////////// #define DATA LATDbits.LATD6 #define STAT LATGbits.LATG6 //////////////////////////////// void Delay_ms(unsigned int time) { unsigned int first,second; for(first=0;first<time;first++) for(second=0;second<11500;second++) ; } main() { [B]unsigned int time = 500;[/B] TRISD = 0; TRISG = 0; LATD = 0; LATG = 0; while(1) { DATA = ~DATA; Delay_ms(time); STAT = ~STAT; Delay_ms(time); } }
Just see this variable unsigned int time, in MPLAB C32 Compiler it consumes 4-bytes of memory.
When i see Memory Window it says Zero Why??
And when i changed the unsigned int time = 500; to outside the main, means global declaration, it consumes memory and also rom gets incremented.
See this
Even the lines.
unsigned int time;
then time = 500;
Showing different consumption in rom.
I am going to see dis-assembly of this code.
Last edited: