Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help on menu call function and it can't increment while a butten pressed

Status
Not open for further replies.
what it is currently it is displaying, is it displaying junk values or not displaying anything or displaying only 3digits?...
 
it displays 236 only when it reach 255

setup_adc_ports(AN0);
set_adc_channel(0);
delay_ms(10);
value=read_adc();

advalue=value*20;

printf(lcd_putc," mV%04u",advalue);
 
Hi samuel,
what kind of clock you are using setup_adc( ADC_CLOCK_INTERNAL ); ?


Try to put little more delay

delay_ms(100);
value=read_adc();
advalue=value*20;

and if you have the debugger then try to read the value of value variable...
 
clock div 32

my problem is display the digits only

tell me the procedure for 4 digits like 0000 to 9999
how to displays these values
 
hi dj i used these lines printf(lcd_putc,"\f %4u"asd);
the display shows



0-20,40,60...240 and then 4,24,44,64...244 and then 8,28,68.....248and then 12 ,32,52,92....252 and then16,36,56...236 and then again 0 then repeat the process finally 236



set_adc_channel( 0 );
delay_ms(100);
a=read_adc();
asd=a*20;
 
what is the datatype has been used for asd...
Because it seems that the value in the asd can be maximum 8-bit so after 8bit i.e. 255 it is overflowing and starts from 0 again..
It is not having any problem related to LCD because LCD if it is showing the data for 3 digit it will show for the 4 also...

And if you count in your case it is happening the same way i.e. 236+20 = 256 which exceeds 255 and it is overflowing...
 
I have not tried this code... But I think these will work...
void write_16bit(eeprom_location, int16_data)
{
write_eeprom(eeprom_location + 1, int16_data & 0xFF);
int16_data >>= 8;
write_eeprom(eeprom_location, int16_data & 0xFF);
}
 
Last edited:
This word is mapped in program memory location 2007h. This address is beyond the user program memory space. This word can be accessed only during programming.

The following system requirements of PIC can be designated by the configuration word.

View attachment 66368
CP1,CP0 : Flash Program Memory Code Protection Bits.
All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed.
11 : Code protection off
10 : 1F00h to 1FFFh code protected
01 : 1000h to 1FFFh code protected
00 : 0000h to 1FFFh code protected


--------------------------------------------------------------------------------

DEBUG : In-Circuit Debugger Mode
1 : In-Circuit Debugger disabled, RB6 and RB7 are general purpose I/O pins.
0 : In-Circuit Debugger enabled, RB6 and RB7 are dedicated to the debugger.


--------------------------------------------------------------------------------

WRT : Flash Program Memory Write Enable
1 : Unprotected program memory may be written to by EECON control
0 : Unprotected program memory may not be written to by EECON control


--------------------------------------------------------------------------------

CPD : Data EEPROM memory Code Protection
1 : Code protection off
0 : Data EEPROM memory code protected


--------------------------------------------------------------------------------

LVP : Low Voltage In-Circuit Serial Programming Enable bit
1 : RB3/PGM pin has PGM function, low voltage programming enabled
The high voltage programming mode is always available, regardless of the state of the LVP bit.
0 : RB3 is digital I/O, High Voltage on MCLR must be used for programming


--------------------------------------------------------------------------------

BODEN : Brown-out Reset Enable bit
1 : BOR enabled
0 : BOR disabled


--------------------------------------------------------------------------------

PWRTE : Power-up Timer Enable bit
1 : PWRT disabled
0 : PWRT enabled


--------------------------------------------------------------------------------

WDTE : Watchdog Timer Enable bit
1 : WDT enabled
0 : WDT disabled


--------------------------------------------------------------------------------

FOSC1,FOSC0 : Oscillator Selection bits
11 : RC : Resistor/Capacitor oscillator ( Less than 1MHz )
10 : HS : High Speed Crystal/Resonator oscillator ( 4MHz to 20MHz )
01 : XT : Crystal/Resonator oscillator ( Less than 4MHz )
00 : LP : Low Power Crystal oscillator ( Less than 200KHz )
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top