Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

from c code to hex file

Status
Not open for further replies.

emperror123

Member level 5
Joined
Dec 11, 2010
Messages
86
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,880
dear all
i have keep searching from google for converting the c source code to HEX file
but unable to found how does the converter to HEX file
hopefully can teach me on how to do converter to HEX file

here are my source code

Code:
'PIC 16F877A 
Define OSC 16            'oscillator 16 MHz, HS mode 
adcon1 = 6                  'make ports digital I/O 
alloff con %11111111       'all cathodes off 
allon con %00000000        'all cathodes on 
cubeoff con %00001111     'all anodes off 
layer0 con %00001110      'layer 0 Floor enabled

layer1 con %00001101      'layer 1 enabled 
layer2 con %00001011      'layer 2 enabled 
layer3 con %00000111      'layer 3 Top enabled 
x var byte               'x,z general variables 
z var byte 
a var byte [8]           'array variable stores current frame data for LED cathodes 
frame var byte          'single frame repetition rate variable 
trisb = 0                 'portb, pord connects to cathode, portc connects to anode 
trisd = 0 
trisc = 0 
portc = cubeoff         'disable all layers (pnp drivers) 
portd = alloff           'initialize all cathode driving ports to off condition 
portb = alloff 
inout:                 'inout pattern - a subset square and outermost square turn on alternately 
frame = 24           'set frame repetition rate 
a[0] = %11111111         'set initial frame data 
a[1] = %11111111 
a[2] = %10011111 
a[3] = %11111001 
a[4] = %10011111 
a[5] = %11111001 
a[6] = %11111111 
a[7] = %11111111 
inouti:                        'main loop of pattern 
gosub frameout             'ouput current frame 
for z = 0 to 7          'invert frame data to interchange squares 
    a[z] = ~a[z] 
next z     
goto inouti             'go back to main loop 
frameout:                'main frame out subroutine 
for x = 0 to frame         'display pattern as per set frame repetition rate 
    portd = a[0]          'set ports connected to cathode pins for Layer 0 frame data 
    portb = a[1] 
    portc = layer0        'enable layer 0 anodes 
    pause 4              'pause for layer on time - set refresh rate to avoid flickering 
    portc = cubeoff       'disable all layers while changing cathode data from one layer to another 
    portd = a[2]          'set ports connected to cathode pins for Layer 1 frame data 
    portb = a[3]                              
    portc = layer1        'enable layer 1 anodes 
    pause 4              'pause for layer on time - set refresh rate to avoid flickering 
    portc = cubeoff      'disable all layers while changing cathode data from one layer to another 
    portd = a[4]         'set ports connected to cathode pins for Layer 2 frame data 
    portb = a[5] 
    portc = layer2       'enable layer 2 anodes 
    pause 4                'pause for layer on time - set refresh rate to avoid flickering 
    portc = cubeoff    'disable all layers while changing cathode data from one layer to another 
    portd = a[6]         'set ports connected to cathode pins for Layer 3 frame data 
    portb = a[7] 
    portc = layer3      'enable layer 3 anodes

    pause 4        'pause for layer on time - set refresh rate to avoid flickering 
    portc = cubeoff    'disable layers while changing cathode data from one layer to another 
next x 
return                'return to main program 
end
 

How did you get this program ?
you try it in MPLAB **broken link removed**
 

that is Basic not C

and go find a Basic compiler for PIC, like mikrobasic or Oshon PIC
 

i have keep searching from google for converting the c source code to HEX file
but unable to found how does the converter to HEX file
hopefully can teach me on how to do converter to HEX file

What you require for the task is commonly referred to as a compiler.

The compiler takes a high level source code file and essentially converts it to a bin or HEX file.

Also as was previous indicated, your source code appears to be in BASIC language, not C language.


BigDog
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top