Code: Select all
program Usart_Test
dim x as byte
dim result as byte
dim y as word
dim output1 as string[3]
'===============================================================================
sub procedure Soft_Uart_Write_Text(dim byref txt as string[50])
dim i as byte
for i = 0 to Strlen(txt) - 1
Soft_Uart_Write(txt[i])
' delay_ms(10)
next i
end sub
'===============================================================================
main:
OSCCON = $7E ' set for intrc @ 8mhz
ANSEL = 0
'ADCON0.0 = 0
' TRISA = 0 'Configure pins of PORTA as output
'TRISB = %00000100 'Configure first pin of PORTB as input and the rest as output
'INTCON = %10010000 'Enable Interrupts
PORTB =0
TRISB=0
CMCON=7
delay_ms(100)
' PORTB=0
soft_Uart_Init(PORTB,2,5,9600,1)
Delay_ms(100)
PORTA = 0
soft_Uart_Write(13)
soft_Uart_Write(10)
soft_Uart_Write_Text("Hello World!")
' Delay_ms(700)
delay_ms(100)
Soft_I2C_Config(PORTA,1,4)
Soft_I2C_start ' issue I2C start signal
Soft_I2C_write($A0) ' send Config byte via I2C
Soft_I2C_write($00) ' send Hi byte (address of EEPROM location)
Soft_I2C_write($00) ' send Lo byte (address of EEPROM location)
Soft_I2C_write($AA) ' send data to EEPROM
Soft_I2C_stop
delay_ms(10)
Soft_I2C_start ' issue I2C start signal
Soft_I2C_write($A0) ' send Config byte via I2C
Soft_I2C_write($00) ' send Hi byte (address of EEPROM location)
Soft_I2C_write($01) ' send Lo byte (address of EEPROM location)
Soft_I2C_write($55) ' send data to EEPROM
Soft_I2C_stop
delay_ms(10)
Soft_I2C_start ' issue I2C start signal
Soft_I2C_write($A0) ' send Config byte via I2C
Soft_I2C_write($00) ' send Hi byte (address of EEPROM location)
Soft_I2C_write($00) ' send Lo byte (address of EEPROM location)
Soft_I2C_Start ' issue I2C signal repeated start
Soft_I2C_write($A1) ' send byte (request data from EEPROM)
result = Soft_I2C_read(0) ' Read the data
Soft_I2C_stop
delay_ms(10)
ByteToStr(result, output1)
soft_Uart_Write_Text(output1)
Soft_I2C_start ' issue I2C start signal
Soft_I2C_write($A0) ' send Config byte via I2C
Soft_I2C_write($00) ' send Hi byte (address of EEPROM location)
Soft_I2C_write($01) ' send Lo byte (address of EEPROM location)
Soft_I2C_Start ' issue I2C signal repeated start
Soft_I2C_write($A1) ' send byte (request data from EEPROM)
result = Soft_I2C_read(0) ' Read the data
Soft_I2C_stop
delay_ms(10)
ByteToStr(result, output1)
soft_Uart_Write_Text(output1)
end.
34 348 Return value of the function "Soft_Uart_Write_Text" is not defined Usart_Test.mbas
38 304 Syntax error: Expected "end" but "main" found Usart_Test.mbas
38 304 Syntax error: Expected "." but ":" found Usart_Test.mbas
0 102 Finished (with errors): 15 Apr 2009, 18:37:52 usart_test.mbppi
Any idea's what is wrong?
Texy