I brought some code that I used in a picaxe08m over to PBP to try and complete a project that the picaxe couldnt handle. Ive been messing with this for over 5 hours today and my head hurts.
The code below works fine with a 12f675 to display 3 digits on three, 7-segment displays using a dedicated driver and shiftout commands.
Code:
DEFINE OSC 4
ANSEL=%00000000
CMCON=7
digit1 var byte
digit2 var byte
digit3 var byte
high 2
digit1 = 0
digit2 = 0
digit3 = 0
gosub configMC
main:
digit1 = 1
digit2 = 2
digit3 = 3
gosub updateMC
pause 500
goto main
end
configMC:
LOW 2
SHIFTOUT 1, 0, 1, [%1]
HIGH 2
return
updateMC:
LOW 2
SHIFTOUT 1, 0, 1, [240 + digit1,digit2,digit3]
HIGH 2
return
My issues are with getting the serin command to work correctly with a variable. I setup a BS2 to send out serial characters with the following code. This is set at 2400,8,N,1.
Code:
Main:
DO
SEROUT 0, 16780, ["4"]
PAUSE 500
LOOP
END
On the 12f675 side I added to the above code, the following...
If I run the BS2 into hyperterminal it displays a 4 as it should every half second. The 12f675 displays a C instead of a 4. It seems to display 1 through 3 fine when sent from the BS2(probably just lucky) but any other integer doesnt work correctly.
My final project is to use 9600,8,N,1 serial that has no flow control option and the data sent as follows...
12.3
12.3
12.1
11.3
Just 2 digits, a dot, and one more digit with a carriage return over and over is sent serially and I need to display this on 7-segment displays.
So, am I making another noob mistake here? Will the 12f675 do serin at 9600 baud? Should I just be using a larger pic with enough I/O to handle three 7-segment displays or is the dedicated driver the way to go?
Thanks all,
Jason
Bookmarks