Hi guys,
This is my first post so forgive me if I'm not thorough enough. For my class, we are using a PIC18f4550 microcontroller. Through the SPP ports, we have a 4-digit, 7-segment display. I will do a lot of explaining for those who do not know much about the 7-segment display.
The problem is as follows:
However, having one microcontroller only allows one display at a time. So in order to display 4 digits simultaneously, say "7312" on the display, I would have to do the following:
Now that I am done explaining how this works, this is the real problem. My code for a digital timer does not fit inside the memory of the PIC18 microcontroller. I don't think I am approaching this correctly, and if there is a much simpler way to do this, I would greatly appreciate it. Here is my code:
Again, any help would be greatly appreciated. This code does NOT work, and after taking almost 3 hours to compile, it gave me a bunch of "warnings" with this message: Address exceeds maximum range for this processor.
Perhaps there is a much easier way to do this with registers?
This is my first post so forgive me if I'm not thorough enough. For my class, we are using a PIC18f4550 microcontroller. Through the SPP ports, we have a 4-digit, 7-segment display. I will do a lot of explaining for those who do not know much about the 7-segment display.
The problem is as follows:
For the sake of brevity, I developed binary definitions for selecting the digits (either 1,2,3, or 4 on the display), and binary definitions for the segment patterns. In addition, I created a "display(x,y)" macro and a "delay_1ms" function. When the "display(x,y)" macro is called, it will display x on y. Ex. display(seg3,digit2) will show up as [x,3,x,x] where x is denoted as nothing. The delay_1ms function will do exactly as described, and do a bunch of "nops."Write a program which will display elapsed time from start of program in hundredths of a second (no decimal point). The four-digit display should be refreshed at a rate of 250 Hz (e.g. 1 msec/digit).
However, having one microcontroller only allows one display at a time. So in order to display 4 digits simultaneously, say "7312" on the display, I would have to do the following:
Rich (BB code):
Main:
display seg7,digit1
call delay_1ms
display seg3,digit2
call delay_1ms
display seg1,digit3
call delay_1ms
display seg2,digit4
call delay_1ms
bra Main
Rich (BB code):
main:
local d1 = 0
local d2 = 0
local d3 = 0
local d4 = 4
while d1 <= 9
d2 = 0
while d2 <= 9
d3 = 0
while d3 <= 9
d4 = 0
while d4 <= 9
display seg#v(d1),digit1
call delay_1ms
display seg#v(d2),digit2
call delay_1ms
display seg#v(d3),digit3
call delay_1ms
display seg#v(d4),digit4
call delay_1ms
d4 += 1
endw
d3 += 1
endw
d2 += 1
endw
d1 += 1
endw
stop bra stop
Perhaps there is a much easier way to do this with registers?