Assembly Tutorial Problem

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
NIKOLAOS
Posts: 8
Joined: Wed Nov 24, 2010 7:02 pm
Has thanked: 3 times
Contact:

Assembly Tutorial Problem

Post by NIKOLAOS »

Hello

I have the assemply student version and the developer board V.3 with PIC 16F88 on it. In tutorial 32, which is an alarm system, there is a bidirectional use of portA and portB. RB7 is used as alarm's on/off switch.But when I press it (RB7) the alarm turns on all zones and the buzzer/siren meaning a general alarm on with the counter BELL1,BELL2 shown on LCD counting down and the time of the alarm on too.But simultaneusly RB0 and RB4 are toggling on and off continiously (after RB7 is pressed).After another press alarm turns off as expected with the time show working all right and the zone message is all right too.It looks like that when PORTB change direction as input except of RB7, RBO-RB3 are all set which makes me suspicious about timing matter.But also BELL counter in some digits shows symbols instead of numbers. I didn't check it well but may be there is the need of ASCII conversion by adding H"30". I have tried with 4Mhz XTAL, and with RC oscillator too with variable rv1 values with no result. As configuration word I used H"3F2A"' but and H'3F29' too and I had cleared the ANSEL register (H'9B').Also in the section CHKZON where the direction is changing and there is a nop command I added some more nops or a delay loop with no result too.

Thank you

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: ASSEMPLY TUTORIAL PROBLEM

Post by Jan Lichtenbelt »

Dear NIKOLAOS

You quote:
NIKOLAOS wrote:.....But also BELL counter in some digits shows symbols instead of numbers. I didn't check it well but may be there is the need of ASCII conversion by adding H"30". ....

Some digits are shown correct and some not. That seems a kind of (stack) overflow to me.

If you want more help. Please be more specific in your question and attach the source.

Kind regards

Jan Lichtenbelt

NIKOLAOS
Posts: 8
Joined: Wed Nov 24, 2010 7:02 pm
Has thanked: 3 times
Contact:

Re: ASSEMPLY TUTORIAL PROBLEM

Post by NIKOLAOS »

Hello Mr Jan

Thank you for your reply.I didn't wrote more because this is a matrix's fix lesson in the assembly cd and to be honest I wasn't expected that somone else would like to answer.It is written for pic 16f84 but the development board that I have is V.3 with pic16f88. All lessons till this one went well except once at the beginning when I hadn't disable LVP programming on RB3.I also have cleared ansel. The tutorial is an alarm system with an 16X2 LCD screen where a real time clock is shown in the second line and a message with zones status in the first line. RB0-RB3 are the zone inputs and the LCD data having a bidirectional use.RB4,5 are LCD's RS and Enable signals.The non alarm status works well.The subroutine where the direction is changing is CHKZON.The only part of PORTB in this subroutine that is working as expected is RB7 whitch is alarm's on/off switch.When it is pressed the alarm turns on but immediately gives a general alarm with PORTA0,1 on as siren/buzzer output and all the zones (RB0-RB3) triggered and shown in the LCD first line and the trigger time too.Also there is a two byte counter (BELL1,BELL2) which counts down for about 10 minutes.The sequence is the following ?>=<;:9876543210.This means that it is not as I have described before.The count down uses all the digits from 9 to 0 but it use the above additional symbols which are the next after 9 ASCII characters.The initial BELL1 value is H'40' which is in ASCII the @.Minus 1 is the ? so the above sequence happens naturaly.But I have noticed on the program's relative command line the comment "show bell count 1 in hex (program test)"so is as it is.Just it confused me because of the other problem which took my most care and I didn't checked well the kind of counting. After alarm on with RB7 which gives immediately general alarm the unusual counting made me think that is part of the problem.I hope general alarm is not another program test.PORTA is used bidirectional too as time set input and as siren/buzzer output and it works well.The difference is that it is not changing direction frequently.So when PORTB7 is pressed again the alarm turns off normaly and the previous status comes up with time and zones in the LCD screen normaly.But the code attachment I think it will describe much better the program than me.

Best regards and thanks a lot
Papaliouras Nikolaos
Attachments
TUT32 ALARM.ASM
(11.31 KiB) Downloaded 436 times

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: ASSEMPLY TUTORIAL PROBLEM

Post by Jan Lichtenbelt »

Dear Papaliouras Nikolaos

It is not that simple. I read your descpition of the problem and I looked at the program. For me it is not possible to help you further. I'm sorry.

In general: You have a LCD conencted to the PIC16F88. This makes debugging possible on an easy way. Show variables on the screen you want to follow and use a wait subroutine if necessary.

Good luck,

Jan Lichtenbelt

NIKOLAOS
Posts: 8
Joined: Wed Nov 24, 2010 7:02 pm
Has thanked: 3 times
Contact:

Re: ASSEMPLY TUTORIAL PROBLEM

Post by NIKOLAOS »

Thank you anyway mrJan. LCD works fine.I didn't wrote anywhere that there is an Lcd problem.LCD is tested with regression harness with scrolling messages etc and is very accurate.Also I wrote that I have tried delay subroutine.What I wrote is that it seems like when portb changes direction as input, when pressing RB7 to switch on the alarm it carries out RB0-RB3 set on high giving that way all zones triggered.But I think matrix should give me a help.I can not post a hole tutorial in a forum.

Honestly thank you for your try
Best regards
Papaliouras Nikolaos

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: ASSEMPLY TUTORIAL PROBLEM

Post by medelec35 »

Hiya NIKOLAOS.
I believe Jan is not saying you have a problem with LCD, but you can use the LCD to display variables. Then you can check if they are assigned with correct value.
In other words you can use the LCD display as a debugging tool.
I do that myself sometimes.
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ASSEMPLY TUTORIAL PROBLEM

Post by Benj »

Hello Nikolaos.

We have been having a look here at the problem you mentioned but we are struggling to find out exactly what the problem is.

When you convert PortB to an input the LEDs are being driven by the LCD which has internal pull up resistors on data lines RB0 - RB3. Could this be what is causing the problem? You may have to clear the port after converting back to an output before you control the LCD.

Also if you are pressing the switches on PortB then you are actually overriding the signals going to the LCD which is probably causing the corruption you are seeing.

If you can detail exactly where the problem lies then hopefully we will be able to help you to get the program working correctly. Alternativly you could remove the 16F88 and the 19.6608MHz crystal from the board and replace with the 16F84A and 3.27MHz crystal the course was designed for.

NIKOLAOS
Posts: 8
Joined: Wed Nov 24, 2010 7:02 pm
Has thanked: 3 times
Contact:

Re: ASSEMPLY TUTORIAL PROBLEM

Post by NIKOLAOS »

Hello

My last thought was that I might have a feedback from the LCD or of a part of the circuit and yes it is very possible that this is the problem .I also had made a thought to disable the PORTB's pullup resistors but I didn't done yet. Also PORTA is used bidirectional and works that way ok. I can not even catch up a key press of RB0-RB3 because when I turn on the alarm by pressing the RB7 the zones are triggered in "miliseconds" with no other action meaning that with RB7 simultaneus RB0-RB3 are high too.I also tried as you suggested me to clear PORTB after changing to output but with no result.AlsoI tried key press of any of RB0-RB3 on every situation and it could not override LCD.Also I will try a delay between LCD Enable alteration.I will post my results.

Thanks a lot everyone
Last edited by NIKOLAOS on Thu Jan 27, 2011 3:52 pm, edited 1 time in total.

NIKOLAOS
Posts: 8
Joined: Wed Nov 24, 2010 7:02 pm
Has thanked: 3 times
Contact:

Re: ASSEMPLY TUTORIAL PROBLEM

Post by NIKOLAOS »

Hello to everyone

First I disabled completly the LCD by the switch on the board.I realised that the problem remains by PORTA0,1 which after RB7 press was on immediately. Then after turning on the LCD I disaled the PORTB,s pull up resistors on the option register and that's it.All went as it should,except that RB0 and RB4 flashing after RB7 is on which is the next it must be found but may be this is natural because alarm is not supposed to drive leds by PORTB.RB0 even if it is flashing is working as input trigger zone well.The crystal that I used at all the clock tutorials is 4MHz .I will aware if something new come up.If there is an idea for this last and less problem I would needed any help.

Thanks Ben and everybody always

Post Reply