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.

urgent HELP!!

Status
Not open for further replies.

kelly_pei

New Member
urgent HELP!!converting to assembly code

//can anyone help me convert it to PIC 18 assembly code? Thank you!!//

#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#define use_portb_lcd TRUE

#byte porta=5
#byte portb=6

#include <lcd.c>

long int read_val;
int val1, val2;

void main()
{

set_tris_b(0x00); // Config PORTA 1st pin as I/p
setup_port_a(all_analog);
setup_adc(adc_clock_internal);
set_adc_channel(0);
lcd_init();

lcd_putc("Temperature");

do
{
read_val = read_adc(); // Read 0th channel
read_val = read_val/2;
val1 = read_val/10;
val2 = read_val%10;
val1 = val1 + '0';
val2 = val2 + '0';
lcd_gotoxy (1,2);
lcd_putc(val1);
lcd_putc(val2);
delay_ms(50);
}while(1);
}
 
Last edited:

Hero.sl

New Member
PIC18 assembly code?

This is CCS C code. If you have the IDE, you can view corresponding assembly code by clicking the ASM list button in the compile tool bar. (I assume that u want the assembly code for the above C code)
 

kelly_pei

New Member
cause i dun hav this IDE software. can anyone convert it to assembly code then post it here again please? really appreciate, thanks...
 

kelly_pei

New Member
read_val = read_adc();
read_val = read_val/2;
val1 = read_val/10;
val2 = read_val%10;
val1 = val1 + '0';
val2 = val2 + '0';


can anyone plz tell wat these means?
 

rajbex

Member
What are you trying to read through ADC channel? I mean what is the input?
read_val = read_adc(); means read the input analog signal and the digital value will be stored in read_val variable.
read_val/2 is divide the number by 2. Why divide by 2? It can be understood only when you will tell us what is the input to the ADC channel?
read_val/10 gives you the tens digit of the value to be displayed on LCD.
read_val%10 gives you the ones digit to be displayed.
To display on LCD, you need to send a character code for each of these numbers. 48 is the code value for displayin '0', 49 for '1', 50 for '2', and so on. So I think, the last two lines are there for the same reason. I would say, val1 = val1 + 48;
val2 = val2 + 48; should equally work, I am not sure though how it works in CCS.

- Raj
Experiments with PIC16F628A
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top