johankj
New Member
Hello all. This is my first post, althought I've been reading this forum quite a bit. Excellent stuff! Anyways, I hope there is someone out there that can help me with my little PIC-Chip.
I'm a novice with PICs, but I have a good project which require RS232. I have managed to to it with a 16F627, but I need ADC on a small footsprint, so I went for the 12F675.
After I rewrote the code to fit the 12F675, I just couldn't get it working. I was banging my head against the wall for weeks, but I just couldn't figure out why.
My suspicion is that I overwrote the OSCCAL values. I'm not sure if I can read the location of that value, since the programmer I'm using (Velleman) is not that good. If I jump to that address, as part of the recommended calibrarion routine, the PIC hangs. I'm pretty sure it's lost, is this what you would expect from an overwritten OSCCAL value? 3F3F, I'm not even sure what that transelates to in Opcode. I've ordered a proper programmer, which should arrive next week
BTW: Two good links to pages regarding OSCCAL:
**broken link removed**
**broken link removed**
I'll post my code below for anyone to check. Sorry for the mess, couldn't get the table thing to work. I've written it as simple as possible, with no trixi parts. Is my code ok? Does it do what I want it to do? (Which is to output an ASCII letter every now and then )
I'm gonna order a few more of those 12F675, and see if I can't get it working. Any advice on the above would be most appreciated, to recap: Is my code OK, and have I overwritten OSCCAL?
Does anyone know the aproximate frequency-range for the internal oscilator?
Oh, and the project I'm doing with this particular PIC is a circut that samples temperature and moisture, and sends it down RS232. I will actually use this on work. I'll post the whole project when it's done, if anyones interested.
All replies are most welcome. And thanks again everyone for an excellent forum.
I'm a novice with PICs, but I have a good project which require RS232. I have managed to to it with a 16F627, but I need ADC on a small footsprint, so I went for the 12F675.
After I rewrote the code to fit the 12F675, I just couldn't get it working. I was banging my head against the wall for weeks, but I just couldn't figure out why.
My suspicion is that I overwrote the OSCCAL values. I'm not sure if I can read the location of that value, since the programmer I'm using (Velleman) is not that good. If I jump to that address, as part of the recommended calibrarion routine, the PIC hangs. I'm pretty sure it's lost, is this what you would expect from an overwritten OSCCAL value? 3F3F, I'm not even sure what that transelates to in Opcode. I've ordered a proper programmer, which should arrive next week
BTW: Two good links to pages regarding OSCCAL:
**broken link removed**
**broken link removed**
I'll post my code below for anyone to check. Sorry for the mess, couldn't get the table thing to work. I've written it as simple as possible, with no trixi parts. Is my code ok? Does it do what I want it to do? (Which is to output an ASCII letter every now and then )
list p=12F675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_oFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
;***Set up the Constants
COUNT1 equ 20h ; First counter for our delay loops
COUNT2 equ 21h ; Second counter for our delay loops
RS232TX equ 23h ; Variable byte to send on RS232
RS232LC equ 24h ; RS232 Delay Loop counter
RS232BC equ 25h ; RS232 Bit counter (0 to 7)
;***Set up the port & Initialise
bcf STATUS, RP0 ; Bank 0
clrf GPIO ; Init GPIO
movlw 0x7 ; Set GP<2:0> to digital IO? (07h not 0x7)
movwf CMCON ; Disable comparator
bsf STATUS, RP0 ; Bank 1
clrf ANSEL ; Digital IO, disables ADC
; call 0x3ff ; Get Calibation value
; movwf OSCCAL ; Calibrate
movlw B'00100000' ; Set GPIO
movwf TRISIO ; All pins outputs, except GPIO5
bcf STATUS, RP0 ; Bank 0
MOVLW b'01010101' ; Byte to be sent. Not implemented.
MOVWF RS232TX ;
bcf GPIO,2 ; Clear GPIO2, initialization for RS232
;*** Start of main loop
Effect1
movlw b'00000100' ; Start bit
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
;*** Start LSB
movlw b'00000100' ; LSB (0)
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
movlw b'00000000' ; 1
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
movlw b'00000100' ; 2
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
movlw b'00000000' ; 3
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
movlw b'00000100' ; 4
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
movlw b'00000000' ; 5
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
movlw b'00000000' ; 6
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
movlw b'00000100' ; MSB (7)
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
;*** End MSB
movlw b'00000000' ; Stop bit
movwf GPIO ;
call RS232BitDelay ; Wait for 104uS
call Delay ; The long wait
call Delay ;
goto Effect1 ;
;*** Bit Delay for RS232
RS232BitDelay ; This loop loops for exactly one bit to be
MOVLW 0x18 ; Pushed on an RS232 line 9600,1,N
MOVWF RS232LC
RS232Loop
nop
DECFSZ RS232LC,1
goto RS232Loop
return
;*** Longer wait
Delay
Loop1 decfsz COUNT1,1 ; This second loop keeps the LED
goto Loop1 ; turned off long enough for us to
decfsz COUNT2,1 ; see it turned off
goto Loop1 ;
return
end
;****End of the program****
I'm gonna order a few more of those 12F675, and see if I can't get it working. Any advice on the above would be most appreciated, to recap: Is my code OK, and have I overwritten OSCCAL?
Does anyone know the aproximate frequency-range for the internal oscilator?
Oh, and the project I'm doing with this particular PIC is a circut that samples temperature and moisture, and sends it down RS232. I will actually use this on work. I'll post the whole project when it's done, if anyones interested.
All replies are most welcome. And thanks again everyone for an excellent forum.