Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Basiclanguage to C language

Status
Not open for further replies.

Zanna

New Member
hi...anyone can help me to convert this to C since i only have ccs compiler to compile the program instead of the PICbasic compiler..


'Serial A/D converter and toxic gas program

Low 1 'Bring I/o to clock low
stat:
Gosub serial_in
'LCD routine
Serout 3, N2400, (254,1)
Pause 1
Serout3, N2400, (#b0)
Pause 100 'Let me see the display
if b0 > 190 Then fan1 'Turn fan on
If b0 < 191 Then fan2 'Turn fan off
Goto start
'Serial in routine
serial_in:
Low 2 'Bring CS down low
bit7 = pin 0 'Load bit 7 into B0
Pulsout 1,1 'Bring CLK pin high, then low
bit6 = pin0 'Load bit 6 into B0
Pulaout 1,1 'Bring CLK pin high, then low
bit5 = pin0 'Load bit 5 into B0
Pulsout 1,1 'Bring CLK pin high, then low
bit4 = pin0 'Load bit 4 into B0
Pulsout 1,1 'Bring CLK pin high, then low
bit3 = pin0 'Load bit 3 into B0
Pulsout 1,1 'Bring CLK pin high, then low
bit2 = pin0 'Load bit 2 into B0
Pulsout 1,1 'Bring CLK pin high, then low
bit1 = pin0 'Load bit 1 into B0
Pulsout 1,1 'Bring CLK pin high, then low
bit0 = pin0 'Load bit 0 into B0
Pulsout 1,1
High 2 'Bring CS high
Return
fan1:
High 4
Goto start
fan2:
Low 4
Goto start
 
Changing other languages int C isn't easy - there is no program I know of that will do it. This program is simple enough that you would be better off just rewriting it yourself.

If you really want to use this code you can compile the basic into assembly and then use the assembly with your C code (a lot of C compilers wil let you use assembly code segments).
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top