ngeronikolos
- 2nd March 2008, 13:59
Hello to everybody,
I use the 16F648A with internal OSC 4Mhz and I power it with 3VDC.The microcontroller does not work well.
I do not manage to find the fault of my code!!!!!
Have a look to the BEGIN MAIN LOOP (of my code).THE IF condition never get TRUE!!!!(That is the reason I add the blink led)
Please have a look and advice
----------------------------------------------------------------------
include "modedefs.bas"
@ DEVICE pic16F648A, INTRC_OSC_NOCLKOUT ' system clock options
@ DEVICE pic16F648A, WDT_ON ' watchdog timer
@ DEVICE pic16F648A, PWRT_ON ' power-on timer
@ DEVICE pic16F648A, MCLR_OFF ' master clear options (internal)
@ DEVICE pic16F648A, BOD_OFF ' brown-out detect
@ DEVICE pic16F648A, LVP_OFF ' low-voltage programming
@ DEVICE pic16F648A, CPD_OFF ' data memory code Protect
@ DEVICE pic16F648A, PROTECT_OFF ' program code protection
PAUSE 500
DEFINE OSC 4 'OSC MUST BE SET TO HS
'general purpose variables
i VAR BYTE
counter var byte
'pin definitions for comm w/ Laipec TRW-24G
RF_CE var PORTB.7
RF_CS var PORTB.6
RF_DR var PORTB.5
'channel 1
RF_CLK1 var PORTB.4
RF_DATA_Out var PORTB.3
' THIS IS THE ADDRESS FOR THE w/ Laipec TRW-24G
WhichAddress1 var byte 'Channel 1
WhichAddress2 var byte 'Channel 2
'constants for RF configuration modes
CONRFRX var byte
CONRFTX var byte
'indicates state of current RF configuration - TX is 0, RX is 1
RFCurrentState var bit
'hold data for RF message
RFDataArrayIN var byte[4]
RFDataArrayOUT var BYTE[4]
'hold data for RF configuration
RFConfigArray var Byte[16]
'variables for each received or sent message
msgFromID var word
msgToID var word
msgData1 var word
msgData2 var word
SerialData VAR BYTE
sendLED var PORTA.0
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''
bootup:
WhichAddress1 =$BA
WhichAddress2 =$BA
PORTA = %00000000;
TRISA = %00011110; ' 0 = Output, 1 = Input (A.1 is RxPC)
PORTB = %00000000;
;TRISB = %01101010; ' 0 = Output, 1 = Input (C.1 is RF_DATA_In, C.3 is RF_DR)
'intialize RF module configuration
'constants to define receive/transmit modes at 2402 Mhz frequency
CONRFTX = $04
RFCurrentState = CONRFTX
GOSUB initRFConfig
'************************BEGIN MAIN LOOP***********************'
start:
IF PORTA.1 = 1 THEN A
goto start
A: low RF_CS ' bring CS low before turning CE high - only one high at a time!
HIGH RF_CE ' bring CE high to bring RF into active mode
high sendLED
pause 1000
low sendLED
msgToID = 000 ' CHANGE THIS TP WHO SHOULD RECIEVE MESSAGE
msgFromID = 001
msgData1 = 001 ' DATA SENT
msgData2 = 000
gosub sendData ' goto the sendData function
pause 200
goto start
sendData : mpla
mpla
mpla
RETURN
END
I use the 16F648A with internal OSC 4Mhz and I power it with 3VDC.The microcontroller does not work well.
I do not manage to find the fault of my code!!!!!
Have a look to the BEGIN MAIN LOOP (of my code).THE IF condition never get TRUE!!!!(That is the reason I add the blink led)
Please have a look and advice
----------------------------------------------------------------------
include "modedefs.bas"
@ DEVICE pic16F648A, INTRC_OSC_NOCLKOUT ' system clock options
@ DEVICE pic16F648A, WDT_ON ' watchdog timer
@ DEVICE pic16F648A, PWRT_ON ' power-on timer
@ DEVICE pic16F648A, MCLR_OFF ' master clear options (internal)
@ DEVICE pic16F648A, BOD_OFF ' brown-out detect
@ DEVICE pic16F648A, LVP_OFF ' low-voltage programming
@ DEVICE pic16F648A, CPD_OFF ' data memory code Protect
@ DEVICE pic16F648A, PROTECT_OFF ' program code protection
PAUSE 500
DEFINE OSC 4 'OSC MUST BE SET TO HS
'general purpose variables
i VAR BYTE
counter var byte
'pin definitions for comm w/ Laipec TRW-24G
RF_CE var PORTB.7
RF_CS var PORTB.6
RF_DR var PORTB.5
'channel 1
RF_CLK1 var PORTB.4
RF_DATA_Out var PORTB.3
' THIS IS THE ADDRESS FOR THE w/ Laipec TRW-24G
WhichAddress1 var byte 'Channel 1
WhichAddress2 var byte 'Channel 2
'constants for RF configuration modes
CONRFRX var byte
CONRFTX var byte
'indicates state of current RF configuration - TX is 0, RX is 1
RFCurrentState var bit
'hold data for RF message
RFDataArrayIN var byte[4]
RFDataArrayOUT var BYTE[4]
'hold data for RF configuration
RFConfigArray var Byte[16]
'variables for each received or sent message
msgFromID var word
msgToID var word
msgData1 var word
msgData2 var word
SerialData VAR BYTE
sendLED var PORTA.0
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''
bootup:
WhichAddress1 =$BA
WhichAddress2 =$BA
PORTA = %00000000;
TRISA = %00011110; ' 0 = Output, 1 = Input (A.1 is RxPC)
PORTB = %00000000;
;TRISB = %01101010; ' 0 = Output, 1 = Input (C.1 is RF_DATA_In, C.3 is RF_DR)
'intialize RF module configuration
'constants to define receive/transmit modes at 2402 Mhz frequency
CONRFTX = $04
RFCurrentState = CONRFTX
GOSUB initRFConfig
'************************BEGIN MAIN LOOP***********************'
start:
IF PORTA.1 = 1 THEN A
goto start
A: low RF_CS ' bring CS low before turning CE high - only one high at a time!
HIGH RF_CE ' bring CE high to bring RF into active mode
high sendLED
pause 1000
low sendLED
msgToID = 000 ' CHANGE THIS TP WHO SHOULD RECIEVE MESSAGE
msgFromID = 001
msgData1 = 001 ' DATA SENT
msgData2 = 000
gosub sendData ' goto the sendData function
pause 200
goto start
sendData : mpla
mpla
mpla
RETURN
END