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.

what is spost to be left out in this asm program?

Status
Not open for further replies.

egg0900

New Member
00235
0000 00236 ORG 0x00
0000 0025 00237 MOVWF OSCCAL
00238
0001 0A31 00239 GOTO start
00240
00241
00242 ; **************************************************************
00243 ; Subroutines
00244 ;
00245
00246
00247 ; **************************************************************
0002 00248 send_char
00249
00250 ; Call send_char with an ASCII character code in W. This is a
00251 ; simple serial output routine which sends the character out
00252 ; serially on an output pin at 1200 baud, 8 data bits, no parity,
00253 ; 1 stop bit. Assume the PIC oscillator is running at 4MHz.
00254 ;
00255 ; The baud rate of 1200 baud was chosen as it will work with the
00256 ; 12C509 internal RC oscillator generating the timing. Higher
00257 ; baud rates require tighter timing tolerance, and will therefore
00258 ; require a crystal.
00259 ;
00260 ; Normally serial communication (RS232) requires a negative
00261 ; voltage between -5V to -15V to represent a ’1’, and a positive
00262 ; voltage between +5V and +15V to represent a ’0’. Most PC
00263 ; serial ports will switch at +/-3V, and in fact will often work
00264 ; with 0V and 5V, so it is possible to use a PIC I/O pin, set
00265 ; high for a logic ’0’ and low for a logic ’1’. A 1k resistor
00266 ; placed in series with the Tx line will limit the current, and
00267 ; This is probably acceptable for experimental purposes. For
00268 ; robustness, however, it may be desirable to include level shift
00269 ; IC, such as the MAX232A from Maxim. The invert_tx compilation
00270 ; option can be used to alter the sense of transmitted bits if
00271 ; necessary.
00272 ;
00273 ; At 1200 baud each bit cell is just over 833us in length. At
00274 ; power up the serial output line is set to its idle state (logic
00275 ; ’1’). At the start of transmission it is taken to logic ’0’
00276 ; for one bit time to generate the start bit. Next, the 8 bits
00277 ; of character data are shifted out, LSB first, by rolling them
00278 ; down into the carry. The program sets or clears the serial
00279 ; line pin according to whether the carry represents a logic ’0’
00280 ; or ’1’. Finally the line is held at logic ’1’ for at least one
00281 ; bit time for the stop bit. The line then rests at this state
00282 ; (idle) until it is time to send the next byte
00283 ;
00284 ; Bit cell timing is done by counting clock cycles: 1 instruction
00285 ; is 1us, jumps and skips are 2us.
00286
0002 002B 00287 MOVWF char_buf ; Store the character code (in W)
00288 ; to character buffer
00289
0003 0C0A 00290 MOVLW .10 ; Set the number of bits (including
0004 0029 00291 MOVWF count ; start and stop bits) in count
00292
 
This is a section of a .LST file, created by MPASM/MPLAB. You don't really mention what you want - but if you want to assemble from that you will have to remove all the numbers at the left hand side.
 
what is spost to be left out in this asm file?

what about the value?

00026 ; **************************************************************
00027 ; General Equates
00028
00029 ; PIC12C509 standard registers
00000000 00030 INDF EQU 0x00
00000001 00031 TMR0 EQU 0x01
00000002 00032 PC EQU 0x02
00000003 00033 STATUS EQU 0x03
00000004 00034 FSR EQU 0x04
00000005 00035 OSCCAL EQU 0x05
00000006 00036 GPIO EQU 0x06 ; lower 5 bits only
00037
00038
00039 ; I/O port bits
00000000 00040 GP0 EQU 0x00
00000001 00041 GP1 EQU 0x01
00000002 00042 GP2 EQU 0x02 ; Shared with T0CKI
00000003 00043 GP3 EQU 0x03 ; Always input, shared with MCLR, Vpp
00000004 00044 GP4 EQU 0x04 ; Shared with OSC2
00000005 00045 GP5 EQU 0x05 ; Shared with OSC1, clkin
00046
00047
00048 ; Status register bit 00000000 00049 C EQU 0x00 ; Carry flag
00000001 00050 DC EQU 0x01 ; Digit carry flag
00000002 00051 Z EQU 0x02 ; Zero flag
00000003 00052 PD EQU 0x03 ; Power down flag
00000004 00053 TO EQU 0x04 ; WDT timeout flag
00000005 00054 PA0 EQU 0x05 ; Program page select
00000007 00055 GPWUF EQU 0x07 ; GPIO reset bit
00056
00057

the numberd forinstance 00027-00057 i guess are the linnes in the program but, what about the values? do i take them out also? Can you show me a way using this code for example to what is needed to burn it to the eprom
 
asm file set up

INDF EQU 0x00
TMR0 EQU 0x01
PC EQU 0x02
STATUS EQU 0x03
FSR EQU 0x04
OSCCAL EQU 0x05
GPIO EQU 0x06 ; lower 5 bits only
GP0 EQU 0x00
GP1 EQU 0x01
GP2 EQU 0x02 ; Shared with T0CKI
GP3 EQU 0x03 ; Always input, shared with MCLR, Vpp
GP4 EQU 0x04 ; Shared with OSC2
GP5 EQU 0x05 ; Shared with OSC1, clkin


Should it look like this before it is converted to hex?
 
Yes, you'll get warnings of the code not beiing aligned properly (labels and code should be separated from each other with tab's) but it'll compile (assuming there are no errors)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top