Try this
rom unsigned char text[] = "EDA BOARD";
unsigned char *textptr;
and in main() initialize
No Sir, This doesn't works.
I found one code on internet and it is as follow:-
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
| #include <p18F27J53.h>
#include <delays.h>
#include <string.h>
/******************CONFIGURATION BITS****************/
#pragma config WDTEN = OFF //WDT disabled (enabled by SWDTEN bit)
#pragma config PLLDIV = 5 //Divide by 5 (20 MHz oscillator input)
#pragma config STVREN = ON //stack overflow/underflow reset enabled
#pragma config XINST = OFF //Extended instruction set disabled
#pragma config CPUDIV = OSC1 //No CPU system clock divide
#pragma config CP0 = OFF //Program memory is not code-protected
#pragma config OSC = HSPLL //HS oscillator, PLL enabled, HSPLL used by USB
#pragma config FCMEN = OFF //Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF //Two-Speed Start-up disabled
#pragma config WDTPS = 32768 //1:32768
#pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
#pragma config RTCOSC = T1OSCREF //RTCC uses T1OSC/T1CKI as clock
#pragma config DSBOREN = OFF //Zero-Power BOR disabled in Deep Sleep
#pragma config DSWDTEN = OFF //Disabled
#pragma config DSWDTPS = 8192 //1:8,192 (8.5 seconds)
#pragma config IOL1WAY = OFF //IOLOCK bit can be set and cleared
#pragma config MSSP7B_EN = MSK7 //7 Bit address masking
#pragma config WPFP = PAGE_1 //Write Protect Program Flash Page 0
#pragma config WPEND = PAGE_0 //Start protection at page 0
#pragma config WPCFG = OFF //Write/Erase last page protect Disabled
#pragma config WPDIS = OFF //WPFP[5:0], WPEND, and WPCFG bits ignored
#pragma config CFGPLLEN = OFF
/****************************************************/
/****************PIN DETAILS****************/
#define LCD_RS PORTCbits.RC0
#define LCD_RW PORTCbits.RC1
#define LCD_EN PORTCbits.RC2
#define LCD_DATA PORTB
#define CURSOR_OFF 0x0C
#define LCD_CLEAR 0x01
#define FIRST_ROW 0x80
#define SECOND_ROW 0xC0
/*******************************************/
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime);
void Lcd_Init(void);
void Lcd_Cmd(unsigned char value);
void Lcd_Data(unsigned char value);
void Lcd_Text(unsigned char msg[]);
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src);
/*******************************************************/
const rom unsigned char text[] = "EDA BOARD";
const rom unsigned char name[] = "Arun Sharma";
unsigned char msg[16];
void main()
{
Lcd_Init();
ConstToRAM(msg,text);
Lcd_Text(msg);
ConstToRAM(msg,name);
Lcd_Cmd(SECOND_ROW);
Lcd_Text(msg);
while(1);
}
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime)
{
#ifndef __DELAY_IN_SEC
#define __DELAY_IN_SEC
unsigned int first;
unsigned int second;
#endif
for(first=0;first<itime;first++)
{
for(second=0;second<650;second++)
{
Delay1TCY();
}
}
}
void Lcd_Cmd(unsigned char value)
{
LCD_DATA = value;
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 1;
Delay_ms(2);
LCD_EN = 0;
Delay_ms(1);
}
void Lcd_Data(unsigned char value)
{
LCD_DATA = value;
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
Delay_ms(2);
LCD_EN = 0;
Delay_ms(1);
}
void Lcd_Init(void)
{
TRISB = 0x00;
TRISCbits.TRISC0 = 0;
TRISCbits.TRISC1 = 0;
TRISCbits.TRISC2 = 0;
Lcd_Cmd(0x38); //Lcd_Initialize
Delay_ms(10);
Lcd_Cmd(CURSOR_OFF);
Delay_ms(10);
Lcd_Cmd(LCD_CLEAR);
Delay_ms(10);
Lcd_Cmd(FIRST_ROW);
Delay_ms(5);
}
void Lcd_Text(unsigned char msg[])
{
while(*msg)
{
Lcd_Data(*msg);
msg++;
}
}
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
/*for(;*dest++ = *src++;)
;*/
while(*src)
{
*dest++ = *src++;
}
return dest;
}
/*******************************************************/ |
I understand this code, but i want to ask some thing related to for loop.
Code:
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
/*for(;*dest++ = *src++;)
;
*/
while(*src)
{
*dest++ = *src++;
}
return dest;
}
The code i found, used the above for loop, i changed it and use my while loop.
I want to know, how they had used that for loop.
And yes i am not getting any warning in my program now and even my ram space is saved also
- - - Updated - - -
Try this
rom unsigned char text[] = "EDA BOARD";
unsigned char *textptr;
and in main() initialize
No Sir, This doesn't works.
I found one code on internet and it is as follow:-
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
| #include <p18F27J53.h>
#include <delays.h>
#include <string.h>
/******************CONFIGURATION BITS****************/
#pragma config WDTEN = OFF //WDT disabled (enabled by SWDTEN bit)
#pragma config PLLDIV = 5 //Divide by 5 (20 MHz oscillator input)
#pragma config STVREN = ON //stack overflow/underflow reset enabled
#pragma config XINST = OFF //Extended instruction set disabled
#pragma config CPUDIV = OSC1 //No CPU system clock divide
#pragma config CP0 = OFF //Program memory is not code-protected
#pragma config OSC = HSPLL //HS oscillator, PLL enabled, HSPLL used by USB
#pragma config FCMEN = OFF //Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF //Two-Speed Start-up disabled
#pragma config WDTPS = 32768 //1:32768
#pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
#pragma config RTCOSC = T1OSCREF //RTCC uses T1OSC/T1CKI as clock
#pragma config DSBOREN = OFF //Zero-Power BOR disabled in Deep Sleep
#pragma config DSWDTEN = OFF //Disabled
#pragma config DSWDTPS = 8192 //1:8,192 (8.5 seconds)
#pragma config IOL1WAY = OFF //IOLOCK bit can be set and cleared
#pragma config MSSP7B_EN = MSK7 //7 Bit address masking
#pragma config WPFP = PAGE_1 //Write Protect Program Flash Page 0
#pragma config WPEND = PAGE_0 //Start protection at page 0
#pragma config WPCFG = OFF //Write/Erase last page protect Disabled
#pragma config WPDIS = OFF //WPFP[5:0], WPEND, and WPCFG bits ignored
#pragma config CFGPLLEN = OFF
/****************************************************/
/****************PIN DETAILS****************/
#define LCD_RS PORTCbits.RC0
#define LCD_RW PORTCbits.RC1
#define LCD_EN PORTCbits.RC2
#define LCD_DATA PORTB
#define CURSOR_OFF 0x0C
#define LCD_CLEAR 0x01
#define FIRST_ROW 0x80
#define SECOND_ROW 0xC0
/*******************************************/
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime);
void Lcd_Init(void);
void Lcd_Cmd(unsigned char value);
void Lcd_Data(unsigned char value);
void Lcd_Text(unsigned char msg[]);
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src);
/*******************************************************/
const rom unsigned char text[] = "EDA BOARD";
const rom unsigned char name[] = "Arun Sharma";
unsigned char msg[16];
void main()
{
Lcd_Init();
ConstToRAM(msg,text);
Lcd_Text(msg);
ConstToRAM(msg,name);
Lcd_Cmd(SECOND_ROW);
Lcd_Text(msg);
while(1);
}
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime)
{
#ifndef __DELAY_IN_SEC
#define __DELAY_IN_SEC
unsigned int first;
unsigned int second;
#endif
for(first=0;first<itime;first++)
{
for(second=0;second<650;second++)
{
Delay1TCY();
}
}
}
void Lcd_Cmd(unsigned char value)
{
LCD_DATA = value;
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 1;
Delay_ms(2);
LCD_EN = 0;
Delay_ms(1);
}
void Lcd_Data(unsigned char value)
{
LCD_DATA = value;
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
Delay_ms(2);
LCD_EN = 0;
Delay_ms(1);
}
void Lcd_Init(void)
{
TRISB = 0x00;
TRISCbits.TRISC0 = 0;
TRISCbits.TRISC1 = 0;
TRISCbits.TRISC2 = 0;
Lcd_Cmd(0x38); //Lcd_Initialize
Delay_ms(10);
Lcd_Cmd(CURSOR_OFF);
Delay_ms(10);
Lcd_Cmd(LCD_CLEAR);
Delay_ms(10);
Lcd_Cmd(FIRST_ROW);
Delay_ms(5);
}
void Lcd_Text(unsigned char msg[])
{
while(*msg)
{
Lcd_Data(*msg);
msg++;
}
}
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
/*for(;*dest++ = *src++;)
;*/
while(*src)
{
*dest++ = *src++;
}
return dest;
}
/*******************************************************/ |
I understand this code, but i want to ask some thing related to for loop.
Code:
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
/*for(;*dest++ = *src++;)
;
*/
while(*src)
{
*dest++ = *src++;
}
return dest;
}
The code i found, used the above for loop, i changed it and use my while loop.
I want to know, how they had used that for loop.
And yes i am not getting any warning in my program now and even my ram space is saved also