Exact match. Not showing close matches.
PICList
Thread
'[PIC]: page boundary on wave generator'
2001\05\12@093727
by
E Jr
|
part 1 2270 bytes content-type:text/plain; charset=iso-8859-1; format=flowedHi all PIClisters
I tryed to build a wave generator PIC16F84 based. The entire system is an
impedance meter. As you know we can study the system by it's response to a
Fourier series. I've mixed at least 5 waves with different amplitudes and
fase shift, bla, bla, bla...
All of this look like:
PIC(wave generator) => DAC0808 (8bits) => I/V converter => transducer
Everything is ok with DAC till transducer. My real problem is to use a table
in PIC to put values on PORTB. My table assumes 512 samples with 8bit
lenght(256 levels). I use the PICLIST/math to help me with long tables that
crosses page boundary. Everything is fine on MPLAB, the two tables can be
easily read, but in real world it doesn't work at all!!!
For the first time I use a simple rising and falling ramp to test, as you
can see in the attached program, but in the scope the signal was splitted
and the second table wasn't read ! In the program memory, there are at least
one page crossing for each table.
table1:
start address: 0x0053 one page boundary crossing at 0x0100
end address: 0x0154
table2
start address: 0x0155 one page boundary crossing at 0x0200
end address: 0x0244
The main program do:
- pick a value on the table
- wait for a tmr0 tick
- put the value on portB
- do it all 256 times for table1
- repeat the process to the table2
- do it all above for ever...
With the scope I saw a saw-tooth like this:
- - ---1,5 V (maximum value)
- | - |
- | - |
- | - |
- | - |
- | - |
- | - |
- -
There is a problem with this signal. The real maximum value is 2,00V (end of
scale for ADC), but the value showed is 1,5 (75%). So, there is a crack on
the table presentation, I thougth that is caused by page boundary crossing,
am I right ??? And where is the table2 (falling ramp) presentation???
The table2 wasn't showed !!!
Please, can someone help me to solve the mistery???
I appreciate any suggestions...
Eduardo Lopes.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
part 2 15135 bytes content-type:text/plain; name="gerador3.asm"; format=flowed
(unknown type 8bit not decoded)
list p=16f84
include p16f84a.inc
__config _wdt_off & _xt_osc & _pwrte_on & _cp_off
cblock 0x0c
contador ;samples counter
timerl ;samples interval
salva ;a safe place to the samples
ajuste ;correction for 390us between samples
multiplicador ;number of interactions
flag ;sample's status
endc
ok equ 0 ;sample catched
escrito equ 1 ;sample written
org 0
goto inicio
org 4
bcf intcon, T0IF ;limpa o flag de interrugco
incfsz TIMERL ;incrementa o contador inferior
retfie ;ainda nco contou valor total
movf ajuste, w ;corregco de tempo
movwf tmr0 ;(grava tmr0)
teste
btfss flag, ok ;testa se o valor novo ja foi lido
retfie ;valor antigo, nco envia
movf salva, w ;pega o valor a ser escrito
movwf portb ;escreve o valor na porta de saida
bsf flag, escrito ;avisa que ja foi escrito
btfss porta, 1 ;pulsa RA1 em cada nivel - RA1 toggle
goto pulo ;de sinal de saida
bcf porta, 1
goto continua
pulo
bsf porta, 1
continua
movf multiplicador, w ;2 iteragues 1*256 + 1* 134 = 390 us
movwf timerl
movf contador, w ;testa se contador = 0
btfss status, z ;ss acende a cada 512 amostras - RA0 toggle
retfie ;
btfss porta, 0
goto sai
bcf porta, 0
retfie
sai
bsf porta, 0
retfie
;=================================================
;PIC setup time
;=================================================
inicio
clrf status
bsf status, rp0
movlw b'11011000' ;clock=>wdt
;prescaler=> wdt / 4 (who cares???)
; pull-ups enabled
movwf option_reg
movlw b'11111100'
movwf trisa
clrf trisb ;portB all outputs
bcf status, rp0
movwf portb
clrf tmr0
movlw 130 ;130 means 389us
movwf ajuste
movlw 254
movwf multiplicador
movwf timerl
clrf flag
bsf intcon, t0ie ;enable tmr0 interruptions
bsf intcon, gie
;========================================================
;TABLE READER
;PICK A VALUE ON THE TABLE AND PUT ON THE SALVA REGISTER
;
;TABLE'S LENGTH = 256
;WITH THESE VALUES WE SHOULD GET A RAMP ON THE DAC
;========================================================
reseta_cont1
clrf contador
loop1
;=====================
;THERE IS A PCLATH CORRECTION FOR PAGES BOUNDARY
;SUGGESTED ON THE PICLIST MATH TABLES
;I THINK THAT IT ISN'T WORKING ON THE REAL WORLD!
;
;PLEASE, CAN SOMEONE TEACH ME THE RIGHT THING?
;===============================================
movlw high(tabela1) ;pega o valor byte alto de enderego
movwf pclath ;e carrega no pclath
movf contador,w ;pega o valor de indice
addlw tabela1 ;e verifica se ultrapassa a tabela
skpnc
incf pclath, f
movf contador, w
call tabela1 ;chama a tabela e
;==============
;SAVE THE SAMPLE ON THE 'SALVA' REGISTER AND WAIT FOR TMR0 TICKS
;==============
movwf salva ; salva o valor da amostra
bsf flag, ok ;avisa que o valor esta pronto
btfss flag, escrito ;verifica se a porta foi escrita
goto $ - 1 ;leva 390us entre amostras
bcf flag, escrito ;
bcf flag,ok ;indica nco pronto, ati termos
incfsz contador, f ;a proxima amostra
;DO IT ALL AGAIN TILL 256 SAMPLES
goto loop1
;================
;DO THE SAME FOR NEXT 256 SAMPLES
;================
reseta_cont2
clrf contador
loop2
movlw high(tabela2) ;pega o valor byte alto de enderego
movwf pclath ;e carrega no pclath
movf contador,w ;pega o valor de indice
addlw tabela2 ;e verifica se ultrapassa a tabela
skpnc
incf pclath, f
movf contador, w
call tabela2
movwf salva
bsf flag, ok ;avisa que o valor esta pronto
btfss flag, escrito ;verifica se a porta foi escrita
goto $ - 1 ;leva 976us entre amostras
bcf flag, escrito ;
bcf flag,ok ;indica nco pronto, ati termos
incfsz contador, f
goto loop2
goto reseta_cont1
;================================
tabela1
addwf pcl, f
retlw 0
retlw 1
retlw 2
retlw 3
retlw 4
retlw 5
retlw 6
retlw 7
retlw 8
retlw 9
retlw 10
retlw 11
retlw 12
retlw 13
retlw 14
retlw 15
retlw 16
retlw 17
retlw 18
retlw 19
retlw 20
retlw 21
retlw 22
retlw 23
retlw 24
retlw 25
retlw 26
retlw 27
retlw 28
retlw 29
retlw 30
retlw 31
retlw 32
retlw 33
retlw 34
retlw 35
retlw 36
retlw 37
retlw 38
retlw 39
retlw 40
retlw 41
retlw 42
retlw 43
retlw 44
retlw 45
retlw 46
retlw 47
retlw 48
retlw 49
retlw 50
retlw 51
retlw 52
retlw 53
retlw 54
retlw 55
retlw 56
retlw 57
retlw 58
retlw 59
retlw 60
retlw 61
retlw 62
retlw 63
retlw 64
retlw 65
retlw 66
retlw 67
retlw 68
retlw 69
retlw 70
retlw 71
retlw 72
retlw 73
retlw 74
retlw 75
retlw 76
retlw 77
retlw 78
retlw 79
retlw 80
retlw 81
retlw 82
retlw 83
retlw 84
retlw 85
retlw 86
retlw 87
retlw 88
retlw 89
retlw 90
retlw 91
retlw 92
retlw 93
retlw 94
retlw 95
retlw 96
retlw 97
retlw 98
retlw 99
retlw 100
retlw 101
retlw 102
retlw 103
retlw 104
retlw 105
retlw 106
retlw 107
retlw 108
retlw 109
retlw 110
retlw 111
retlw 112
retlw 113
retlw 114
retlw 115
retlw 116
retlw 117
retlw 118
retlw 119
retlw 120
retlw 121
retlw 122
retlw 123
retlw 124
retlw 125
retlw 126
retlw 127
retlw 128
retlw 129
retlw 130
retlw 131
retlw 132
retlw 133
retlw 134
retlw 135
retlw 136
retlw 137
retlw 138
retlw 139
retlw 140
retlw 141
retlw 142
retlw 143
retlw 144
retlw 145
retlw 146
retlw 147
retlw 148
retlw 149
retlw 150
retlw 151
retlw 152
retlw 153
retlw 154
retlw 155
retlw 156
retlw 157
retlw 158
retlw 159
retlw 160
retlw 161
retlw 162
retlw 163
retlw 164
retlw 165
retlw 166
retlw 167
retlw 168
retlw 169
retlw 170
retlw 171
retlw 172
retlw 173
retlw 174
retlw 175
retlw 176
retlw 177
retlw 178
retlw 179
retlw 180
retlw 181
retlw 182
retlw 183
retlw 184
retlw 185
retlw 186
retlw 187
retlw 188
retlw 189
retlw 190
retlw 191
retlw 192
retlw 193
retlw 194
retlw 195
retlw 196
retlw 197
retlw 198
retlw 199
retlw 200
retlw 201
retlw 202
retlw 203
retlw 204
retlw 205
retlw 206
retlw 207
retlw 208
retlw 209
retlw 210
retlw 211
retlw 212
retlw 213
retlw 214
retlw 215
retlw 216
retlw 217
retlw 218
retlw 219
retlw 220
retlw 221
retlw 222
retlw 223
retlw 224
retlw 225
retlw 226
retlw 227
retlw 228
retlw 229
retlw 230
retlw 231
retlw 232
retlw 233
retlw 234
retlw 235
retlw 236
retlw 237
retlw 238
retlw 239
retlw 240
retlw 241
retlw 242
retlw 243
retlw 244
retlw 245
retlw 246
retlw 247
retlw 248
retlw 249
retlw 250
retlw 251
retlw 252
retlw 253
retlw 254
retlw 255
tabela2
addwf pcl, f
retlw 255
retlw 254
retlw 253
retlw 252
retlw 251
retlw 250
retlw 249
retlw 248
retlw 247
retlw 246
retlw 245
retlw 244
retlw 243
retlw 242
retlw 241
retlw 240
retlw 239
retlw 238
retlw 237
retlw 236
retlw 235
retlw 234
retlw 233
retlw 232
retlw 231
retlw 230
retlw 229
retlw 228
retlw 227
retlw 226
retlw 225
retlw 224
retlw 223
retlw 222
retlw 221
retlw 220
retlw 219
retlw 218
retlw 217
retlw 216
retlw 215
retlw 214
retlw 213
retlw 212
retlw 211
retlw 210
retlw 209
retlw 208
retlw 207
retlw 206
retlw 205
retlw 204
retlw 203
retlw 202
retlw 201
retlw 200
retlw 199
retlw 198
retlw 197
retlw 196
retlw 195
retlw 194
retlw 193
retlw 192
retlw 191
retlw 190
retlw 189
retlw 188
retlw 187
retlw 186
retlw 185
retlw 184
retlw 183
retlw 182
retlw 181
retlw 180
retlw 179
retlw 178
retlw 177
retlw 176
retlw 175
retlw 174
retlw 173
retlw 172
retlw 171
retlw 170
retlw 169
retlw 168
retlw 167
retlw 166
retlw 165
retlw 164
retlw 163
retlw 162
retlw 161
retlw 160
retlw 159
retlw 158
retlw 157
retlw 156
retlw 155
retlw 154
retlw 153
retlw 152
retlw 151
retlw 150
retlw 149
retlw 148
retlw 147
retlw 146
retlw 145
retlw 144
retlw 143
retlw 142
retlw 141
retlw 140
retlw 139
retlw 138
retlw 137
retlw 136
retlw 135
retlw 134
retlw 133
retlw 132
retlw 131
retlw 130
retlw 129
retlw 128
retlw 127
retlw 126
retlw 125
retlw 124
retlw 123
retlw 122
retlw 121
retlw 120
retlw 119
retlw 118
retlw 117
retlw 116
retlw 115
retlw 114
retlw 113
retlw 112
retlw 111
retlw 110
retlw 109
retlw 108
retlw 107
retlw 106
retlw 105
retlw 104
retlw 103
retlw 102
retlw 101
retlw 100
retlw 99
retlw 98
retlw 97
retlw 96
retlw 95
retlw 94
retlw 93
retlw 92
retlw 91
retlw 90
retlw 89
retlw 88
retlw 87
retlw 86
retlw 85
retlw 84
retlw 83
retlw 82
retlw 81
retlw 80
retlw 79
retlw 78
retlw 77
retlw 76
retlw 75
retlw 74
retlw 73
retlw 72
retlw 71
retlw 70
retlw 69
retlw 68
retlw 67
retlw 66
retlw 65
retlw 64
retlw 63
retlw 62
retlw 61
retlw 60
retlw 59
retlw 58
retlw 57
retlw 56
retlw 55
retlw 54
retlw 53
retlw 52
retlw 51
retlw 50
retlw 49
retlw 48
retlw 47
retlw 46
retlw 45
retlw 44
retlw 43
retlw 42
retlw 41
retlw 40
retlw 39
retlw 38
retlw 37
retlw 36
retlw 35
retlw 34
retlw 33
retlw 32
retlw 31
retlw 30
retlw 29
retlw 28
retlw 27
retlw 26
retlw 25
retlw 24
retlw 23
retlw 22
retlw 21
retlw 20
retlw 19
retlw 18
retlw 17
retlw 16
retlw 15
retlw 14
retlw 13
retlw 12
retlw 11
retlw 10
retlw 9
retlw 8
retlw 7
retlw 6
retlw 5
retlw 4
retlw 3
retlw 2
retlw 1
retlw 0
end
part 3 154 bytes
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
2001\05\12@121351
by
michael brown
You are not saving the W register and STATUS register during interrupt
routine. At the beginning of interrupt routine you need to:
IntStart:
movwf W_TEMP ;Save everything
swapf STATUS, W
movwf STATUS_TEMP
At the end of interrupt routine you need something like(you can replace your
retfie's with goto IntExit):
IntExit:
swapf STATUS_TEMP, W ;restore STATUS register
movwf STATUS
swapf W_TEMP, F ;restore W without affecting
STATUS
swapf W_TEMP, W
retfie
If you don't do this your main loop will experience unexpected changes in
the STATUS and W register when the interrupt routine is executed.
Is your RADIX set to 10 or 16(default) in the project properties? You need
to set "RADIX DEC" option in .asm file for clarity. You have another
warning message (line 26) when I assemble, but it should not cause problems.
Try those changes and see what happens. Good luck.
Michael Brown
Instant Net Solutions
http://www.KillerPCs.net
{Original Message removed}
More... (looser matching)
- Last day of these posts
- In 2001
, 2002 only
- Today
- New search...