pls help me convert C to PICBASIC


Results 1 to 6 of 6

Threaded View

  1. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by marcasjr View Post
    I use Proton+ PICbasic from Crownhill, I use Proteus ISIS Professional as Simulator...
    Proton <> PBP _ Crownhill sponsors their forum too, and also sells that compiler.
    Your Code as posted with my comments in red:
    Code:
    Device 16F877A
    XTAL = 20   <font color=red> DEFINE OSC 20</font color>  
    ALL_DIGITAL = TRUE  <font color=red> Not in PBP 
    
    The following will work but there are better ways.</font color>
    Symbol CS = PORTC.4		       ' SPI eeprom CS line
    Symbol SCK = PORTC.3		      ' Clock pin
    Symbol SI = PORTC.5			' Data in pin
    Symbol SO = PORTC.5		
    <font color=red> Like . . . 
    CS VAR PortC.4
    No Dims in PBP </font color>
    Dim reg as BYTE
    Dim datas[10] as BYTE
    Dim dongu as BYTE
    <font color=red> do it this way
    Dongu VAR BYTE
    Datas VAR BYTE[10]</font color>
    MAX6952_Init:
        PORTC.0=0
    	FOR dongu = 1 to 2
    	Shout SI, SCK, MSBFIRST, [0x04]
    	Shout SI, SCK, MSBFIRST, [0x01] 
    	NEXT
    	PORTC.0=1
    	PORTC.0=0	
    	
    	PORTC.0=0
    	FOR dongu = 1 to 2
    	Shout SI, SCK, MSBFIRST, [0x01]
    	Shout SI, SCK, MSBFIRST, [0xFF] 
    	NEXT
    	PORTC.0=1
    	PORTC.0=0	
    	
    	PORTC.0=0
    	FOR dongu = 1 to 2
    	Shout SI, SCK, MSBFIRST, [0x02]
    	Shout SI, SCK, MSBFIRST, [0xFF] 
    	NEXT
    	PORTC.0=1
    	PORTC.0=0	
    	
    	PORTC.0=0
    	FOR dongu = 1 to 2
    	Shout SI, SCK, MSBFIRST, [0x03]
    	Shout SI, SCK, MSBFIRST, [0x01] 
    	NEXT
    	PORTC.0=1
    	PORTC.0=0	
    
    	Return
    max6952_putchar:
        PORTC.0=0
    	FOR dongu = 1 to 2
    	Shout SI, SCK, MSBFIRST, [reg]
    	Shout SI, SCK, MSBFIRST, [datas[0]] 
    	NEXT
    
    	PORTC.0=1
    	PORTC.0=0			
        
        Return
    
    Main:
    	TRISC=%010001100
    	Goto MAX6952_Init
    	reg=0x20
    	datas[0]="A"
    	Goto max6952_putchar
         Delayms 500<font color=red> Nope! Pause 500</font color>
    Goto main
    That should give you something to chew on a while.
    Last edited by Archangel; - 7th December 2008 at 09:31.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. can anyone here can convert this in picbasic pro?
    By reianjim in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd December 2009, 11:43
  2. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 18:31
  3. Picbasic VS C Compiler
    By koossa in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th October 2005, 21:44
  4. Replies: 22
    Last Post: - 12th July 2005, 17:39
  5. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 10:04

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts