PDA

View Full Version : Found a bug (I think)



Art
- 23rd April 2016, 07:18
Hi Guys,
I can only conclude I found a bug after today’s efforts.
I have 2x16 char LCD connected as default in the manual, except for the enable pin connected to portB bit 2,
and also using hardware serial input, but I don’t want to use serial transmit.

http://img.photobucket.com/albums/v186/ArtArt/Tesla_Schematic_zpsz3a6cpgo.png

It appears I can either use the LCD or hardware serial, but not both.
If HSERIN is ever called, the LCD routines that aren’t seen, I assume, forgets to use the enable pin,
and the LCD never works again for the program session.

Even after disabling the TXSTA and RCSTA registers manually after each HSERIN use, the LCD still does not work.
Connecting the LCD enable pin to portb bit 7 instead fixes everything.

Other than TXSTA and RCSTA registers, I don’t know what else the use of HSERIN could change that could be
restored after each use for the LCD command to work again.
Cheers, Art.

Ioannis
- 23rd April 2016, 11:39
I am sure it is because RB2 is asigned to TX of the USART.

Ioannis

Art
- 23rd April 2016, 12:18
Yes, but that seems to only happen once HSERIN command is actually executed
no matter what HSER defines are at the top of the program.
From there, it should be possible to reverse whatever registers were changed for LCDOUT to work again,
but that doesn’t seem to happen. All of the control bits are in either the TXSTA or RCSTA registers.


I am sure it is because RB2 is asigned to TX of the USART.

Ioannis

tumbleweed
- 23rd April 2016, 13:29
Check out the USART control info in the 16F628A errata document (http://ww1.microchip.com/downloads/en/DeviceDoc/80151N.pdf)

You should be able to get control of the pins by clearing SPEN (RCSTA.7) and restoring the TRISB pin settings.

Ioannis
- 23rd April 2016, 14:58
Also I recall a system variable called FLAGS or something similar that initialize the LCD module after the system has recovered from sleep mode.

See this post too: http://www.picbasic.co.uk/forum/showthread.php?t=8193&p=51653#post51653

Ioannis

Art
- 23rd April 2016, 15:53
I have tried clearing various bits of the registers (including specific serial port enable bits),
but not yet resetting the LCD.
It would be bad though since the LCD is updated every frame, and initialisation is a few commands.
I think maybe I’ll leave as is, and try to control and LED or such with the RB2 pin.