#828 Some times my code doesn't work!!!

closed-rejected
nobody
5
2013-05-25
2004-10-20
Anonymous
No

Hi, my name is Nilton (nilton@iag.usp.br). I´m studing
in Săo Paulo University in Brazil.

I done a Atmel 89s8252 hardware with 32kbyte of RAM and
LCD alphanumeric mapped in memory and one 12 bit ADC
(MAX199) in memory, as well.

I found a strange problem with my system: some times
the system does not get a correct value in ADC, some
times the HBEN pin (0=lsb, 1=msb) stays in one and the
system gets de msb two times and... (I saw it in a
digital osciloscope).

Another interesting think is about the LCD, it is
working very well, all the time, mapped in memory, too!!!

But, I got a solution for this situation replacing the
connection A0 to HBEN by the connection P1_0 to HBEN
and making some changes in my code:

volatile xdata at 0xb000 char lsb_ad; // lsb adc, S3 138
volatile xdata at 0xb001 char msb_ad; // msb adc, S3 138
//volatile xdata at 0xbfff unsigned char fbloco3; //
end of block 3

.
.
.

With de HBEN pin connected to the A0 pin
/************It does not work**********/

lsb_ad=0x48; // to star a convertion
while(int_ad); // waiting for a conversion end
adl=lsb_ad; // read lsb in adl
adh=msb_ad; // read msb en adh
conv=adh*256+adl; // do the value convertion

With the HBEN pin connected to the P1_0
/***********It works very well**********/

lsb_ad=0x48; // to star a convertion
while(int_ad); // waiting for a conversion end
P1_0=0; // enable lsb
adl=lsb_ad; // read lsb in adl
P1_0=1; // enable msb
adh=msb_ad; // read msb en adh
conv=adh*256+adl; // do the value convertion

sdcc -v
SDCC :
mcs51/gbz80/z80/avr/ds390/pic14/TININative/xa51/ds400
2.3.5 (Sep 18 2003) (MINGW32)

Working in windows 95, 486 DX4 100Mhz (Compac Contura
notebook), the oldest machine in my Institute!

So, I don't know what is happend, maybe some my
mistake, but I decided to write this e-mail!!!

Sorry by my poor english and very Thank's.

Discussion

  • Nobody/Anonymous

    Souce C

     
  • Maarten Brock

    Maarten Brock - 2004-10-21

    Logged In: YES
    user_id=888171

    Nilton,

    First, if you want to report a bug, please use a recent version
    of SDCC. Updates are free you know.

    Second, I don't think this is a bug in SDCC but more likely in
    the timing of your design. Have you checked the timing
    requirements in the datasheets of the adc and the mcu? Or
    it's just a loose contact. Have you checked A0 instead of
    HBEN?

    Next time, if you want to ask for help, please use the support
    section or the user-list.

     
  • Maarten Brock

    Maarten Brock - 2004-10-21
    • milestone: --> non_bugs
    • status: open --> closed-rejected
     
  • Maarten Brock

    Maarten Brock - 2004-10-21

    Logged In: YES
    user_id=888171

    Oh, I forgot to mention the Forums which can be used to ask
    for help.

     

Log in to post a comment.