|
|
View previous topic :: View next topic |
Author |
Message |
Marcus Guest
|
Table in pic16f877 |
Posted: Mon Feb 16, 2004 3:52 pm |
|
|
Did you see an error in these function. When i execute them, they didn't send my caracters but other caracters. I don't know why. Did the compilator have problems with pointers?
void main() {
//========Debut du code===========================
//** Initialisations.
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_EXT_L_TO_H,WDT_18MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
init_ext_eeprom();
set_tris_b(0x00); // Mettre le port b en sortie.
set_timer0(0xFF-8);
enable_interrupts(INT_TIMER0);
enable_interrupts(global);
output_b(0x00); // Initialiser le port b à 0.
delay_ms(1000);
EnvoyerString("Menu principal|1) Afficher l'heure|2)Modifier l'heure");
do
{
}
while(1);
}//========Fin du code===========================
void EnvoyerString(char* sChaine)
{
disable_interrupts(global);
while(*sChaine != 0)
{
delay_ms(50);
if(iEnable == 0)
{
iEnable = 1;
*sChaine = *sChaine | 0x80;
}
else
{
iEnable = 0;
*sChaine = *sChaine & 0x7F;
}
output_b(*sChaine); // Envoyer le caractère.
sChaine++;
}
enable_interrupts(global);
} |
|
|
Ttelmah Guest
|
Re: Table in pic16f877 |
Posted: Mon Feb 16, 2004 4:30 pm |
|
|
Marcus wrote: | Did you see an error in these function. When i execute them, they didn't send my caracters but other caracters. I don't know why. Did the compilator have problems with pointers?
void main() {
//========Debut du code===========================
//** Initialisations.
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_EXT_L_TO_H,WDT_18MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
init_ext_eeprom();
set_tris_b(0x00); // Mettre le port b en sortie.
set_timer0(0xFF-8);
enable_interrupts(INT_TIMER0);
enable_interrupts(global);
output_b(0x00); // Initialiser le port b à 0.
delay_ms(1000);
EnvoyerString("Menu principal|1) Afficher l'heure|2)Modifier l'heure");
do
{
}
while(1);
}//========Fin du code===========================
void EnvoyerString(char* sChaine)
{
disable_interrupts(global);
while(*sChaine != 0)
{
delay_ms(50);
if(iEnable == 0)
{
iEnable = 1;
*sChaine = *sChaine | 0x80;
}
else
{
iEnable = 0;
*sChaine = *sChaine & 0x7F;
}
output_b(*sChaine); // Envoyer le caractère.
sChaine++;
}
enable_interrupts(global);
} |
This is definately a case of RTFM.
The compiler has no problems with pointers as such, _but_ you cannot have pointers to _constant_ strings (mapped in the ROM). Your declared strings are automatically of this form.
Best Wishes |
|
|
Marcus Guest
|
|
Posted: Tue Feb 17, 2004 8:11 am |
|
|
Which is the best way to resolve this error? Do a global variable? I've a little problem with global variable, my ram is full if my string is too long. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|