Ok, I’m programming something for a project of the University.
We have to show data through a LCD screen. The problem is that Port A is occupied with the Keyboard, and Port B, and some of Port C is occupied with LCD Data and LCD control.
What I wanted to do is to change Port B to input in the middle of the program, and then change it to output again, but it didn’t semm to work.
I have a MC68HC908GP32.
I asked to motorola, but they seem to ignore me. I just hope someone around here knows about this.
Well, in all honesty, this is a fairly obscure question, and that is likely why no one has responded. I have some experience with programming microcontrollers (Allen Bradley SLC/PLC, Parallax SX, GE Fanuc), and even I’ve never seen code for your type. I even tried a Google search to find help, thinking that there might be an online manual or something.
There are microcontrollers that do not let you change them from Input to Output and back after they startup. What sort of tools do you have available? Any reference docs online? Technical and I/O guides online? Parallax, for example, has all of their stuff downloadable from their website.
All went great until I cleared bit 7, when the simulation said the same thing (port B uninitialized).
I also tried to clear the port after the bit changing of the DDRB, but it didn’t help.
I don’t know how to reset it… I don’t have your simulator. I doubt that’s the issue, I just see that it does, in fact, have a reset.
Looking at the data sheet further, is there some problem with not setting the ADC Channel Select Bits to 1, thus turning off the ADC function, since Port B is a general purpose I/O and not just a digital one?
BTW, how are your friends in class with you doing this?
-lv (who wouldn’t presume to post this unless I knew you were grasping for straws, as I knew nothing about this microprocessor before opening the link.)
My classmates weren’t using the port as an output and input. They were using a space of memory in the RAM to store the data you want to show in the LCD screen, and refresh the screen with this data every certain amount of time. this way they only needed port b as an output. So if they want to use what is written on the screen, they just have to read from the space of memory where it is stored.
I didn’t want to do this, because I will have to change a lot of my previous programming to adapt to that. Instead, I wanted to read from port b, and store that in the RAM.
Thanks for answering LordVor. I have to do some testing with this to see if that is the problem, because when I run the program (in real life), The program seems to change from output to input, and then to output (as I want it), but when I want to show what is stored in the RAM, it doesn’t show what it should.
Maybe it is not even changing the status of the port, or maybe I wrote the reading from LCD routine wrong (which I doubt ;))
I also noticed that that command (DDRB) is for the simulator, and I think that I cannot use it in the WinIDE (assembler) as a command.