Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/20/06 13:48
Read: times


 
#128307 - My Code
Responding to: ???'s previous message
Dear Russell,

My apologies if the explanation so far seem to make no sense at all. This is the 1st time that I'm using a PCA, thus your assistance is much appreciated.

1. The chip simulated is P89C51RD2HBA.

2. Application to generate a linear frequency ramp from 1Khz ~ 40 Khz at increments of 1 Khz.

3. All values have been confirmed to produce the correct frequency & number of pulses using a scope. However at higher frequencies, my suspicions is that something is causing a delay when the PCA is switching frquencies. This is only seen after 16Khz, but not at lower frquencies.

4. My code :

Non_Value holds the number of pulses which is needed.
Value1 is incremented everytime a pulses is generated.


.Main_Program:


.aseg __code, code
.ORG 0000H
LJMP MAIN

.ORG 001BH
LCALL INT_TIMER0
RETI

.ORG 0033H
LJMP PCA_INTERRUPT

Main:
LCALL SETUP_SERIAL_9600
LCALL SETUP_TIMER0
SETB PT0 ; Eric, is this the problem
LCALL F_Counter_up
L140502_01:
MOV R4,#0
LCALL COM_DUMP_RECEIVE
SJMP L140502_01


PCA_INIT: ;Initializa PCA Timer
MOV CMOD,#02H ; Input to PCA Timer = 1/4 * Fosc
MOV CH,#00
MOV CL,#00
MOV CCAPM0,#04DH ; HSO with Interrupt Enabled
MOV CCAP0L,#.LOW(1000) ; Not sure what this does !!!!!
MOV CCAP0H,#.HIGH(1000); Not sure what this does !!!!!
CLR P1.3
SETB EC ; Enable PCA Interrupt
SETB EA
SETB CR
MOV VALUE1,#0

WAIT: ; The following routine controls number of pulses needed
MOV A,VALUE1
cjne a,NON_PULSES,done1
MOV CCAPM0,#00H ; Disable HSO mode
RET

done1: SJMP wait ; Loop number of pulses equals

PCA_INTERRUPT:
CLR CCF0
JNB P1.3,DONE
done2:
PUSH ACC
PUSH PSW
CLR EA
MOV A,FREQ1
ADD A,CCAP0L
MOV CCAP0L,A
MOV A,FREQ2

ADDC A,CCAP0H
MOV CCAP0H,A
SETB EA

POP PSW
POP ACC

RETI

DONE:
inc value1
sjmp done2


F_COUNTER_UP:
MOV FREQ1,#.LOW(3125) ; 1kHZ using 25Mhz Crystal
MOV FREQ2,#.HIGH(3125)
MOV NON_PULSES,#100 ; Number of pulses needed
LCALL PCA_INIT

MOV FREQ1,#.LOW(1563) ; 2Khz using 25Mhz Crystal
MOV FREQ2,#.HIGH(1563)
MOV NON_PULSES,#100 ; Number of pulses needed
LCALL PCA_INIT

; Balance of code is here ( truncated for explanation )

MOV FREQ1,#.LOW(78) ; 40 Khz using 25Mhz Crystal
MOV FREQ2,#.HIGH(78)
MOV NON_PULSES,#100 ; Number of pulses needed
LCALL PCA_INIT

RET


P.S : I've got Cool Edit, however how would one use it to see the pulses

List of 41 messages in thread
TopicAuthorDate
PCA Problems            01/01/70 00:00      
   Problem or deisgn feature?            01/01/70 00:00      
      PCA upsetting Servo Ramp-up            01/01/70 00:00      
         How are you doing this?            01/01/70 00:00      
            more questions            01/01/70 00:00      
            How to connect Cool Edit            01/01/70 00:00      
               does not work            01/01/70 00:00      
                  Pulses generated ok            01/01/70 00:00      
            My Code            01/01/70 00:00      
               ther is your problem            01/01/70 00:00      
               Why are you...            01/01/70 00:00      
                  Assistance Please Russell            01/01/70 00:00      
               A suggestion            01/01/70 00:00      
   Minor Problem in Suggestion            01/01/70 00:00      
      I might have a guess            01/01/70 00:00      
      More comments            01/01/70 00:00      
         Thanks Eric n Russell            01/01/70 00:00      
            A two way street            01/01/70 00:00      
            Lost communication?            01/01/70 00:00      
            not a question of intelligence            01/01/70 00:00      
   This Code Works !            01/01/70 00:00      
      Much better with the comments!            01/01/70 00:00      
      explain a bit here            01/01/70 00:00      
      Moving in the positive            01/01/70 00:00      
         Russell you comment plz !            01/01/70 00:00      
            My comments            01/01/70 00:00      
               Guess you must be right !            01/01/70 00:00      
                  does not work !            01/01/70 00:00      
                     Make it work - thats your job!            01/01/70 00:00      
      Why disable interrupts            01/01/70 00:00      
         I thought the same about the interrupts            01/01/70 00:00      
      Cool Edit            01/01/70 00:00      
         re: Cool Edit            01/01/70 00:00      
            if not square waves - what did you get?            01/01/70 00:00      
               Cool Edit vs Digital Scope            01/01/70 00:00      
                  Cool edit            01/01/70 00:00      
                     Thank You !            01/01/70 00:00      
                     sample rates!!!            01/01/70 00:00      
   Will provide feedback            01/01/70 00:00      
   please help me about visisp52            01/01/70 00:00      
      discussed ad nauseam            01/01/70 00:00      

Back to Subject List